Changeset 2f7134b in mainline
- Timestamp:
- 2018-10-31T06:03:38Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 167616c
- Parents:
- faf19d4
- git-author:
- Jakub Jermar <jakub@…> (2018-10-29 20:55:36)
- git-committer:
- Jakub Jermar <jakub@…> (2018-10-31 06:03:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipcrsc.c
rfaf19d4 r2f7134b 31 31 */ 32 32 /** @file 33 */34 35 /*36 * IPC resources management37 *38 * The goal of this source code is to properly manage IPC resources and allow39 * straight and clean clean-up procedure upon task termination.40 *41 * The pattern of usage of the resources is:42 * - allocate a capability and phone kernel object (do not publish yet),43 * connect to the answerbox, and finally publish the capability44 * - disconnect connected phone (some messages might be on the fly)45 * - find phone capability and send a message using phone46 * - answer message to phone47 * - hangup phone (the caller has hung up)48 * - hangup phone (the answerbox is exiting)49 *50 * Locking strategy51 *52 * - To use a phone, disconnect a phone etc., the phone must be first locked and53 * then checked that it is connected54 * - To connect an allocated phone it need not be locked (assigning pointer is55 * atomic on all platforms)56 *57 * - To answer a message, the answerbox must be locked58 * - The locking of phone and answerbox is done at the ipc_ level.59 * It is perfectly correct to pass unconnected phone to these functions and60 * proper reply will be generated.61 *62 * Locking order63 *64 * - first phone, then answerbox65 * + Easy locking on calls66 * - Very hard traversing list of phones when disconnecting because the phones67 * may disconnect during traversal of list of connected phones. The only68 * possibility is try_lock with restart of list traversal.69 *70 * Destroying is less frequent, this approach is taken.71 *72 * Phone call73 *74 * *** Connect_me_to ***75 * The caller sends IPC_M_CONNECT_ME_TO to an answerbox. The server receives76 * 'phoneid' of the connecting phone as an ARG5. If it answers with RETVAL=EOK,77 * the phone call is accepted, otherwise it is refused.78 *79 * *** Connect_to_me ***80 * The caller sends IPC_M_CONNECT_TO_ME.81 * The server receives an automatically opened phoneid. If it accepts82 * (RETVAL=EOK), it can use the phoneid immediately. Possible race condition can83 * arise, when the client receives messages from new connection before getting84 * response for connect_to_me message. Userspace should implement handshake85 * protocol that would control it.86 *87 * Phone hangup88 *89 * *** The caller hangs up (sys_ipc_hangup) ***90 * - The phone is disconnected (no more messages can be sent over this phone),91 * all in-progress messages are correctly handled. The answerbox receives92 * IPC_M_PHONE_HUNGUP call from the phone that hung up. When all async calls93 * are answered, the phone is deallocated.94 *95 * *** The answerbox hangs up (ipc_answer(EHANGUP))96 * - The phone is disconnected. EHANGUP response code is sent to the calling97 * task. All new calls through this phone get a EHUNGUP error code, the task98 * is expected to call sys_ipc_hangup after cleaning up its internal99 * structures.100 *101 *102 * Call forwarding103 *104 * The call can be forwarded, so that the answer to call is passed directly to105 * the original sender. However, this poses special problems regarding routing106 * of hangup messages.107 *108 * sys_ipc_hangup -> IPC_M_PHONE_HUNGUP109 * - this message CANNOT be forwarded110 *111 * EHANGUP during forward112 * - The *forwarding* phone will be closed, EFORWARD is sent to receiver.113 *114 * EHANGUP, ENOENT during forward115 * - EFORWARD is sent to the receiver, ipc_forward returns error code EFORWARD116 *117 * Cleanup strategy118 *119 * 1) Disconnect all our phones ('ipc_phone_hangup').120 *121 * 2) Disconnect all phones connected to answerbox.122 *123 * 3) Answer all messages in 'calls' and 'dispatched_calls' queues with124 * appropriate error code (EHANGUP, EFORWARD).125 *126 * 4) Wait for all async answers to arrive and dispose of them.127 *128 33 */ 129 34
Note:
See TracChangeset
for help on using the changeset viewer.