Changeset fbcfd458 in mainline for generic/src/ipc/ipcrsc.c


Ignore:
Timestamp:
2006-03-18T23:02:08Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b4b45210
Parents:
ba81cab
Message:

Untested better IPC functions.

  • There is some bug in MIPS, unpredicatbly sometimes the thread gets mapped

different frame for stack.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/ipc/ipcrsc.c

    rba81cab rfbcfd458  
    3737 * - find phone in slot and send a message using phone
    3838 * - answer message to phone
     39 * - hangup phone (the caller has hung up)
     40 * - hangup phone (the answerbox is exiting)
    3941 *
    4042 * Locking strategy
     
    5153 *   and proper reply will be generated.
    5254 *
    53  * - There may be objection that a race may occur when the syscall finds
    54  *   an appropriate call and before executing ipc_send, the phone call might
    55  *   be disconnected and connected elsewhere. As there is no easy solution,
    56  *   the application will be notified by an  'PHONE_DISCONNECTED' message
    57  *   and the phone will not be allocated before the application notifies
    58  *   the kernel subsystem that it does not have any pending calls regarding
    59  *   this phone call.
    60  *
    6155 * Locking order
    6256 *
    63  * There are 2 possibilities
    6457 * - first phone, then answerbox
    6558 *   + Easy locking on calls
     
    6861 *     The only possibility is try_lock with restart of list traversal.
    6962 *
    70  * - first answerbox, then phone(s)
    71  *   + Easy phone disconnect
    72  *   - Multiple checks needed when sending message
     63 * Destroying is less frequent, this approach is taken.
    7364 *
    74  * Because the answerbox destroyal is much less frequent operation,
    75  * the first method is chosen.
     65 * Phone hangup
     66 *
     67 * *** The caller hangs up (sys_ipc_hangup) ***
     68 * - The phone is disconnected (no more messages can be sent over this phone),
     69 *   all in-progress messages are correctly handled. The anwerbox receives
     70 *   IPC_M_PHONE_HUNGUP call from the phone that hung up. When all async
     71 *   calls are answered, the phone is deallocated.
     72 *
     73 * *** The answerbox hangs up (ipc_answer(ESLAM))
     74 * - The phone is disconnected. IPC_M_ANSWERBOX_HUNGUP notification
     75 *   is sent to source task, the calling process is expected to
     76 *   send an sys_ipc_hangup after cleaning up it's internal structures.
    7677 *
    7778 * Cleanup strategy
    7879 *
    79  * 1) Disconnect all phones.
     80 * 1) Disconnect all our phones ('sys_ipc_hangup')
     81 *
     82 * 2) Disconnect all phones connected to answerbox.
    8083 *    * Send message 'PHONE_DISCONNECTED' to the target application
    8184 * - Once all phones are disconnected, no further calls can arrive
    8285 *
    83  * 2) Answer all messages in 'calls' and 'dispatched_calls' queues with
     86 * 3) Answer all messages in 'calls' and 'dispatched_calls' queues with
    8487 *    appropriate error code.
    8588 *
    86  * 3) Wait for all async answers to arrive
    87  * Alternatively - we might try to invalidate all messages by setting some
    88  * flag, that would dispose of the message once it is answered. This
    89  * would need to link all calls in one big list, which we don't currently
    90  * do.
    91  *
     89 * 4) Wait for all async answers to arrive
    9290 *
    9391 */
     
    119117       
    120118        for (i=0; i < IPC_MAX_PHONES; i++) {
    121                 if (!TASK->phones[i].busy) {
     119                if (!TASK->phones[i].busy && !atomic_get(&TASK->phones[i].active_calls)) {
    122120                        TASK->phones[i].busy = 1;
    123121                        break;
     
    131129}
    132130
    133 /** Disconnect phone */
     131/** Disconnect phone a free the slot
     132 *
     133 * All already sent messages will be correctly processed
     134 */
    134135void phone_dealloc(int phoneid)
    135136{
     
    137138
    138139        ASSERT(TASK->phones[phoneid].busy);
    139 
    140         if (TASK->phones[phoneid].callee)
    141                 ipc_phone_destroy(&TASK->phones[phoneid]);
     140        ASSERT(! TASK->phones[phoneid].callee);
    142141
    143142        TASK->phones[phoneid].busy = 0;
Note: See TracChangeset for help on using the changeset viewer.