Changeset fbcfd458 in mainline


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.

Location:
generic
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • generic/include/ipc/ipc.h

    rba81cab rfbcfd458  
    3838
    3939/* Flags for calls */
    40 #define IPC_CALL_ANSWERED      0x1 /**< This is answer to a call */
    41 #define IPC_CALL_STATIC_ALLOC  0x2 /**< This call will not be freed on error */
    42 #define IPC_CALL_DISPATCHED    0x4 /**< Call is in dispatch queue */
     40#define IPC_CALL_ANSWERED     (1<<0) /**< This is answer to a call */
     41#define IPC_CALL_STATIC_ALLOC (1<<1) /**< This call will not be freed on error */
     42#define IPC_CALL_DISPATCHED   (1<<2) /**< Call is in dispatch queue */
     43#define IPC_CALL_DISCARD_ANSWER (1<<3) /**< Answer will not be passed to
     44                                        * userspace, will be discarded */
    4345
    4446/* Flags for ipc_wait_for_call */
    4547#define IPC_WAIT_NONBLOCKING   1
    4648
    47 /* Flags of callid */
    48 #define IPC_CALLID_ANSWERED  1
     49/* Flags of callid (the addresses are aligned at least to 4,
     50 * that is why we can use bottom 2 bits of the call address
     51 */
     52#define IPC_CALLID_ANSWERED       1 /**< Type of this msg is 'answer' */
     53#define IPC_CALLID_NOTIFICATION   2 /**< Type of this msg is 'notification' */
    4954
    5055/* Return values from IPC_ASYNC */
     
    5459
    5560/* Macros for manipulating calling data */
    56 #define IPC_SET_RETVAL(data, retval)   ((data)[0] = (retval))
    57 #define IPC_SET_METHOD(data, val)   ((data)[0] = (val))
    58 #define IPC_SET_ARG1(data, val)   ((data)[1] = (val))
    59 #define IPC_SET_ARG2(data, val)   ((data)[2] = (val))
    60 #define IPC_SET_ARG3(data, val)   ((data)[3] = (val))
    61 
    62 #define IPC_GET_METHOD(data)           ((data)[0])
    63 #define IPC_GET_RETVAL(data)           ((data)[0])
    64 
    65 #define IPC_GET_ARG1(data)              ((data)[1])
    66 #define IPC_GET_ARG2(data)              ((data)[2])
    67 #define IPC_GET_ARG3(data)              ((data)[3])
     61#define IPC_SET_RETVAL(data, retval)   ((data).args[0] = (retval))
     62#define IPC_SET_METHOD(data, val)   ((data).args[0] = (val))
     63#define IPC_SET_ARG1(data, val)   ((data).args[1] = (val))
     64#define IPC_SET_ARG2(data, val)   ((data).args[2] = (val))
     65#define IPC_SET_ARG3(data, val)   ((data).args[3] = (val))
     66
     67#define IPC_GET_METHOD(data)           ((data).args[0])
     68#define IPC_GET_RETVAL(data)           ((data).args[0])
     69
     70#define IPC_GET_ARG1(data)              ((data).args[1])
     71#define IPC_GET_ARG2(data)              ((data).args[2])
     72#define IPC_GET_ARG3(data)              ((data).args[3])
    6873
    6974/* Well known phone descriptors */
     
    9095 *                     - the caller obtains taskid of the called thread
    9196 */
    92 #define IPC_M_CONNECTTOME     1
     97#define IPC_M_CONNECT_TO_ME     1
    9398/** Protocol for CONNECT - ME - TO
    9499 *
     
    109114 *
    110115 */
    111 #define IPC_M_CONNECTMETO     2
    112 /* Control messages that the server sends to the processes
    113  * about their connections.
    114  */
     116#define IPC_M_CONNECT_ME_TO     2
     117/** This message is sent to answerbox when the phone
     118 * is hung up
     119 */
     120#define IPC_M_PHONE_HUNGUP      3
    115121
    116122
     
    129135#define IPC_MAX_PHONES  16
    130136
    131 typedef struct answerbox answerbox_t;
    132 typedef __native ipc_data_t[IPC_CALL_LEN];
    133 
     137typedef struct answerbox_s answerbox_t;
     138typedef struct phone_s phone_t;
    134139typedef struct {
    135         link_t list;
    136         answerbox_t *callerbox;
    137         int flags;
    138         task_t *sender;
    139         ipc_data_t data;
    140 } call_t;
    141 
    142 struct answerbox {
     140        __native args[IPC_CALL_LEN];
     141        phone_t *phone;
     142}ipc_data_t;
     143
     144struct answerbox_s {
    143145        SPINLOCK_DECLARE(lock);
    144146
     
    154156};
    155157
    156 typedef struct {
     158struct phone_s {
    157159        SPINLOCK_DECLARE(lock);
    158160        link_t list;
    159161        answerbox_t *callee;
    160162        int busy;
    161 } phone_t;
     163        atomic_t active_calls;
     164};
     165
     166typedef struct {
     167        link_t list;
     168
     169        int flags;
     170
     171        /* Identification of the caller */
     172        task_t *sender;
     173        /* The caller box is different from sender->answerbox
     174         * for synchronous calls
     175         */
     176        answerbox_t *callerbox;
     177
     178        ipc_data_t data;
     179}call_t;
    162180
    163181extern void ipc_init(void);
     
    166184extern void ipc_call(phone_t *phone, call_t *request);
    167185extern void ipc_call_sync(phone_t *phone, call_t *request);
    168 extern void ipc_phone_destroy(phone_t *phone);
    169186extern void ipc_phone_init(phone_t *phone);
    170187extern void ipc_phone_connect(phone_t *phone, answerbox_t *box);
     
    178195extern answerbox_t *ipc_phone_0;
    179196extern void ipc_cleanup(task_t *task);
     197extern int ipc_phone_hangup(phone_t *phone);
    180198
    181199#endif
  • generic/include/ipc/ipcrsc.h

    rba81cab rfbcfd458  
    3232call_t * get_call(__native callid);
    3333int phone_alloc(void);
     34void phone_connect(int phoneid, answerbox_t *box);
    3435void phone_dealloc(int phoneid);
    35 void phone_connect(int phoneid, answerbox_t *box);
    36 
    3736
    3837#endif
  • generic/include/ipc/sysipc.h

    rba81cab rfbcfd458  
    3131
    3232__native sys_ipc_call_sync_fast(__native phoneid, __native method,
    33                                 __native arg1, __native *data);
    34 __native sys_ipc_call_sync(__native phoneid, __native *question,
    35                            __native *reply);
     33                                __native arg1, ipc_data_t *data);
     34__native sys_ipc_call_sync(__native phoneid, ipc_data_t *question,
     35                           ipc_data_t *reply);
    3636__native sys_ipc_call_async_fast(__native phoneid, __native method,
    3737                                 __native arg1, __native arg2);
    38 __native sys_ipc_call_async(__native phoneid, __native *data);
     38__native sys_ipc_call_async(__native phoneid, ipc_data_t *data);
    3939__native sys_ipc_answer_fast(__native callid, __native retval,
    4040                             __native arg1, __native arg2);
    41 __native sys_ipc_answer(__native callid, __native *data);
     41__native sys_ipc_answer(__native callid, ipc_data_t *data);
    4242__native sys_ipc_connect_to_me(__native phoneid, __native arg1,
    4343                               __native arg2, task_id_t *taskid);
     
    4848__native sys_ipc_forward_fast(__native callid, __native phoneid,
    4949                              __native method, __native arg1);
     50__native sys_ipc_hangup(int phoneid);
    5051
    5152
  • generic/include/syscall/syscall.h

    rba81cab rfbcfd458  
    4646        SYS_IPC_CONNECT_TO_ME,
    4747        SYS_IPC_CONNECT_ME_TO,
     48        SYS_IPC_HANGUP,
    4849        SYSCALL_END
    4950} syscall_t;
  • generic/src/ipc/ipc.c

    rba81cab rfbcfd458  
    124124}
    125125
    126 /** Disconnect phone from answerbox
    127  *
    128  * It is allowed to call disconnect on already disconnected phone\
    129  */
    130 void ipc_phone_destroy(phone_t *phone)
    131 {
    132         answerbox_t *box = phone->callee;
    133        
    134         ASSERT(box);
    135 
    136         spinlock_lock(&phone->lock);
    137         spinlock_lock(&box->lock);
    138 
    139         if (phone->callee) {
    140                 list_remove(&phone->list);
    141                 phone->callee = NULL;
    142         }
    143 
    144         spinlock_unlock(&box->lock);
    145         spinlock_unlock(&phone->lock);
    146 }
    147 
    148126/** Helper function to facilitate synchronous calls */
    149127void ipc_call_sync(phone_t *phone, call_t *request)
     
    191169}
    192170
     171/* Unsafe unchecking ipc_call */
     172static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
     173{
     174        atomic_inc(&phone->active_calls);
     175        call->data.phone = phone;
     176
     177        spinlock_lock(&box->lock);
     178        list_append(&call->list, &box->calls);
     179        spinlock_unlock(&box->lock);
     180        waitq_wakeup(&box->wq, 0);
     181}
     182
    193183/** Send a asynchronous request using phone to answerbox
    194184 *
     
    201191
    202192        spinlock_lock(&phone->lock);
     193
    203194        box = phone->callee;
    204195        if (!box) {
    205196                /* Trying to send over disconnected phone */
     197                spinlock_unlock(&phone->lock);
     198
     199                call->data.phone = phone;
    206200                IPC_SET_RETVAL(call->data, ENOENT);
    207201                _ipc_answer_free_call(call);
    208202                return;
    209203        }
    210 
    211         spinlock_lock(&box->lock);
    212         list_append(&call->list, &box->calls);
    213         spinlock_unlock(&box->lock);
    214         waitq_wakeup(&box->wq, 0);
     204        _ipc_call(phone, box, call);
    215205       
    216206        spinlock_unlock(&phone->lock);
     207}
     208
     209/** Disconnect phone from answerbox
     210 *
     211 * It is allowed to call disconnect on already disconnected phone
     212 *
     213 * @return 0 - phone disconnected, -1 - the phone was already disconnected
     214 */
     215int ipc_phone_hangup(phone_t *phone)
     216{
     217        answerbox_t *box;
     218        call_t *call;
     219       
     220        spinlock_lock(&phone->lock);
     221        box = phone->callee;
     222        if (!box) {
     223                spinlock_unlock(&phone->lock);
     224                return -1;
     225        }
     226
     227        spinlock_lock(&box->lock);
     228        list_remove(&phone->list);
     229        phone->callee = NULL;
     230        spinlock_unlock(&box->lock);
     231
     232        call = ipc_call_alloc();
     233        IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
     234        call->flags |= IPC_CALL_DISCARD_ANSWER;
     235        _ipc_call(phone, box, call);
     236
     237        phone->busy = 0;
     238
     239        spinlock_unlock(&phone->lock);
     240
     241        return 0;
    217242}
    218243
     
    226251{
    227252        spinlock_lock(&oldbox->lock);
     253        atomic_dec(&call->data.phone->active_calls);
    228254        list_remove(&call->list);
    229255        spinlock_unlock(&oldbox->lock);
     
    242268        call_t *request;
    243269
    244         spinlock_lock(&box->lock);
    245         while (1) {
    246                 if (!list_empty(&box->answers)) {
    247                         /* Handle asynchronous answers */
    248                         request = list_get_instance(box->answers.next, call_t, list);
    249                         list_remove(&request->list);
    250                 } else if (!list_empty(&box->calls)) {
    251                         /* Handle requests */
    252                         request = list_get_instance(box->calls.next, call_t, list);
    253                         list_remove(&request->list);
    254                         /* Append request to dispatch queue */
    255                         list_append(&request->list, &box->dispatched_calls);
    256                         request->flags |= IPC_CALL_DISPATCHED;
    257                 } else {
    258                         if (!(flags & IPC_WAIT_NONBLOCKING)) {
    259                                 /* Wait for event to appear */
    260                                 spinlock_unlock(&box->lock);
    261                                 waitq_sleep(&box->wq);
    262                                 spinlock_lock(&box->lock);
    263                                 continue;
    264                         }
    265                         request = NULL;
    266                 }
    267                 break;
     270restart:     
     271        if (flags & IPC_WAIT_NONBLOCKING) {
     272                if (waitq_sleep_timeout(&box->wq,0,1) == ESYNCH_WOULD_BLOCK)
     273                        return NULL;
     274        } else
     275                waitq_sleep(&box->wq);
     276       
     277        spinlock_lock(&box->lock);
     278        if (!list_empty(&box->answers)) {
     279                /* Handle asynchronous answers */
     280                request = list_get_instance(box->answers.next, call_t, list);
     281                list_remove(&request->list);
     282                printf("%d %P\n", IPC_GET_METHOD(request->data),
     283                       request->data.phone);
     284                atomic_dec(&request->data.phone->active_calls);
     285        } else if (!list_empty(&box->calls)) {
     286                /* Handle requests */
     287                request = list_get_instance(box->calls.next, call_t, list);
     288                list_remove(&request->list);
     289                /* Append request to dispatch queue */
     290                list_append(&request->list, &box->dispatched_calls);
     291                request->flags |= IPC_CALL_DISPATCHED;
     292        } else {
     293                printf("WARNING: Spurious IPC wakeup.\n");
     294                spinlock_unlock(&box->lock);
     295                goto restart;
    268296        }
    269297        spinlock_unlock(&box->lock);
  • 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;
  • generic/src/ipc/sysipc.c

    rba81cab rfbcfd458  
    4343#include <proc/thread.h>
    4444
    45 /* TODO: multi-threaded connect-to-me can cause race condition
    46  * on phone, add counter + thread_kill??
    47  *
    48  */
    49 
    5045#define GET_CHECK_PHONE(phone,phoneid,err) { \
    5146      if (phoneid > IPC_MAX_PHONES) { err; } \
     
    5348}
    5449
     50#define STRUCT_TO_USPACE(dst,src) copy_to_uspace(dst,src,sizeof(*src))
    5551
    5652/** Return true if the method is a system method */
     
    6965static inline int is_forwardable(__native method)
    7066{
     67        if (method == IPC_M_PHONE_HUNGUP)
     68                return 0; /* This message is meant only for the receiver */
    7169        return 1;
    7270}
     
    8280static inline int answer_will_preprocess(call_t *call)
    8381{
    84         if (IPC_GET_METHOD(call->data) == IPC_M_CONNECTTOME)
     82        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME)
    8583                return 1;
    86         if (IPC_GET_METHOD(call->data) == IPC_M_CONNECTMETO)
     84        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_ME_TO)
    8785                return 1;
    8886        return 0;
     
    9492        int phoneid;
    9593
    96         if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECTTOME) {
     94        if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
    9795                phoneid = IPC_GET_ARG3(*olddata);
    9896                if (IPC_GET_RETVAL(answer->data)) {
     
    103101                        phone_connect(phoneid,&answer->sender->answerbox);
    104102                }
    105         } else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECTMETO) {
     103        } else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {
    106104                /* If the users accepted call, connect */
    107105                if (!IPC_GET_RETVAL(answer->data)) {
     
    131129        int phoneid;
    132130
    133         if (IPC_GET_METHOD(call->data) == IPC_M_CONNECTTOME) {
     131        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) {
    134132                phoneid = phone_alloc();
    135133                if (phoneid < 0) { /* Failed to allocate phone */
     
    149147 */
    150148__native sys_ipc_call_sync_fast(__native phoneid, __native method,
    151                                 __native arg1, __native *data)
     149                                __native arg1, ipc_data_t *data)
    152150{
    153151        call_t call;
     
    165163        ipc_call_sync(phone, &call);
    166164
    167         copy_to_uspace(data, &call.data, sizeof(call.data));
     165        STRUCT_TO_USPACE(&data->args, &call.data.args);
    168166
    169167        return 0;
     
    171169
    172170/** Synchronous IPC call allowing to send whole message */
    173 __native sys_ipc_call_sync(__native phoneid, __native *question,
    174                            __native *reply)
     171__native sys_ipc_call_sync(__native phoneid, ipc_data_t *question,
     172                           ipc_data_t *reply)
    175173{
    176174        call_t call;
     
    178176
    179177        ipc_call_static_init(&call);
    180         copy_from_uspace(&call.data, question, sizeof(call.data));
     178        copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args));
    181179
    182180        if (is_system_method(IPC_GET_METHOD(call.data)))
     
    187185        ipc_call_sync(phone, &call);
    188186
    189         copy_to_uspace(reply, &call.data, sizeof(call.data));
     187        STRUCT_TO_USPACE(&reply->args, &call.data.args);
    190188
    191189        return 0;
     
    238236 * @return The same as sys_ipc_call_async
    239237 */
    240 __native sys_ipc_call_async(__native phoneid, __native *data)
     238__native sys_ipc_call_async(__native phoneid, ipc_data_t *data)
    241239{
    242240        call_t *call;
     
    249247
    250248        call = ipc_call_alloc();
    251         copy_from_uspace(&call->data, data, sizeof(call->data));
     249        copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args));
    252250
    253251        if (is_system_method(IPC_GET_METHOD(call->data))) {
     
    335333
    336334/** Send IPC answer */
    337 inline __native sys_ipc_answer(__native callid, __native *data)
     335__native sys_ipc_answer(__native callid, ipc_data_t *data)
    338336{
    339337        call_t *call;
     
    349347                preprocess = 1;
    350348        }
    351         copy_from_uspace(&call->data, data, sizeof(call->data));
     349        copy_from_uspace(&call->data.args, &data->args,
     350                         sizeof(call->data.args));
    352351
    353352        if (preprocess)
     
    370369
    371370        ipc_call_static_init(&call);
    372         IPC_SET_METHOD(call.data, IPC_M_CONNECTTOME);
     371        IPC_SET_METHOD(call.data, IPC_M_CONNECT_TO_ME);
    373372        IPC_SET_ARG1(call.data, arg1);
    374373        IPC_SET_ARG2(call.data, arg2);
     
    379378
    380379        if (!IPC_GET_RETVAL(call.data) && taskid)
    381                 copy_to_uspace(taskid,
    382                                &phone->callee->task->taskid,
    383                                sizeof(TASK->taskid));
     380                STRUCT_TO_USPACE(taskid, &phone->callee->task->taskid);
    384381
    385382        return IPC_GET_RETVAL(call.data);
     
    404401
    405402        ipc_call_static_init(&call);
    406         IPC_SET_METHOD(call.data, IPC_M_CONNECTMETO);
     403        IPC_SET_METHOD(call.data, IPC_M_CONNECT_ME_TO);
    407404        IPC_SET_ARG1(call.data, arg1);
    408405        IPC_SET_ARG2(call.data, arg2);
     
    419416}
    420417
     418/** Hang up the phone
     419 *
     420 *
     421 *
     422 */
     423__native sys_ipc_hangup(int phoneid)
     424{
     425        phone_t *phone;
     426
     427        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
     428
     429        if (ipc_phone_hangup(phone))
     430                return -1;
     431
     432        return 0;
     433}
     434
    421435/** Wait for incoming ipc call or answer
    422436 *
    423  * Generic function - can serve either as inkernel or userspace call
    424  * - inside kernel does probably unnecessary copying of data (TODO)
    425  *
    426  * @param result
    427  * @param taskid
     437 * @param calldata Pointer to buffer where the call/answer data is stored
     438 * @param taskid On 'CONNECT_ME_TO' call it is filled with 'taskid' of
     439 *               the caller.
    428440 * @param flags
    429441 * @return Callid, if callid & 1, then the call is answer
    430442 */
    431 inline __native sys_ipc_wait_for_call(ipc_data_t *calldata,
    432                                       task_id_t *taskid,
    433                                       __native flags)
     443__native sys_ipc_wait_for_call(ipc_data_t *calldata, task_id_t *taskid,
     444                               __native flags)
    434445                                             
    435446{
     
    443454                        goto restart;
    444455
    445                 copy_to_uspace(calldata, &call->data, sizeof(call->data));
     456                ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
     457
    446458                atomic_dec(&TASK->active_calls);
    447                 ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
     459
     460                if (call->flags & IPC_CALL_DISCARD_ANSWER) {
     461                        ipc_call_free(call);
     462                        goto restart;
     463                }
     464
     465                STRUCT_TO_USPACE(&calldata->args, &call->data.args);
    448466                ipc_call_free(call);
    449467
    450468                return ((__native)call) | IPC_CALLID_ANSWERED;
    451469        }
     470
    452471        if (process_request(&TASK->answerbox, call))
    453472                goto restart;
    454         copy_to_uspace(calldata, &call->data, sizeof(call->data));
    455         copy_to_uspace(taskid, (void *)&TASK->taskid, sizeof(TASK->taskid));
     473
     474        /* Include phone address('id') of the caller in the request */
     475        STRUCT_TO_USPACE(calldata, &call->data);
     476        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_ME_TO)
     477                STRUCT_TO_USPACE(taskid, &TASK->taskid);
    456478        return (__native)call;
    457479}
    458 
  • generic/src/proc/scheduler.c

    rba81cab rfbcfd458  
    353353                switch (THREAD->state) {
    354354                    case Running:
    355                         THREAD->state = Ready;
    356355                        spinlock_unlock(&THREAD->lock);
    357356                        thread_ready(THREAD);
  • generic/src/proc/task.c

    rba81cab rfbcfd458  
    160160                t = list_get_instance(cur, task_t, tasks_link);
    161161                spinlock_lock(&t->lock);
    162                 printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d",
     162                printf("%s: address=%P, taskid=%Q\n\tas=%P, ActiveCalls: %d",
    163163                        t->name, t, t->taskid, t->as, atomic_get(&t->active_calls));
    164164                for (i=0; i < IPC_MAX_PHONES; i++) {
  • generic/src/proc/thread.c

    rba81cab rfbcfd458  
    184184        spinlock_lock(&t->lock);
    185185
     186        ASSERT(! (t->state == Ready));
     187
    186188        i = (t->priority < RQ_COUNT -1) ? ++t->priority : t->priority;
    187189       
     
    416418        for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) {
    417419                t = list_get_instance(cur, thread_t, threads_link);
    418                 printf("%s: address=%P, tid=%d, state=%s, task=%P, code=%P, stack=%P, cpu=",
     420                printf("%s: address=%P, tid=%d, state=%s\n\ttask=%P, code=%P, stack=%P, cpu=",
    419421                        t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack);
    420422                if (t->cpu)
  • generic/src/syscall/syscall.c

    rba81cab rfbcfd458  
    7878        sys_ipc_wait_for_call,
    7979        sys_ipc_connect_to_me,
    80         sys_ipc_connect_me_to
     80        sys_ipc_connect_me_to,
     81        sys_ipc_hangup
    8182};
Note: See TracChangeset for help on using the changeset viewer.