Changeset b1f51f0 in mainline for libc/generic/ipc.c


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

Changed recommended way of asynchronous communication.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/ipc.c

    ra116ef22 rb1f51f0  
    134134
    135135/** Epilogue of ipc_async_send functions */
    136 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, async_call_t *call)
     136static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
     137                                    async_call_t *call, int can_preempt)
    137138{
    138139        if (callid == IPC_CALLRET_FATAL) {
     
    149150
    150151                call->u.msg.phoneid = phoneid;
    151 
    152                 call->ptid = psthread_get_id();
     152               
    153153                futex_down(&async_futex);
    154154                list_append(&call->list, &queued_calls);
    155155
    156                 psthread_schedule_next_adv(PS_TO_MANAGER);
    157                 /* Async futex unlocked by previous call */
     156                if (can_preempt) {
     157                        call->ptid = psthread_get_id();
     158                        psthread_schedule_next_adv(PS_TO_MANAGER);
     159                        /* Async futex unlocked by previous call */
     160                } else {
     161                        call->ptid = 0;
     162                        futex_up(&async_futex);
     163                }
    158164                return;
    159165        }
     
    172178void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
    173179                      ipcarg_t arg2, void *private,
    174                       ipc_async_callback_t callback)
     180                      ipc_async_callback_t callback, int can_preempt)
    175181{
    176182        async_call_t *call;
     
    191197                IPC_SET_ARG2(call->u.msg.data, arg2);
    192198        }
    193         ipc_finish_async(callid, phoneid, call);
     199        ipc_finish_async(callid, phoneid, call, can_preempt);
    194200}
    195201
     
    201207void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
    202208                      ipcarg_t arg2, ipcarg_t arg3, void *private,
    203                       ipc_async_callback_t callback)
     209                      ipc_async_callback_t callback, int can_preempt)
    204210{
    205211        async_call_t *call;
     
    219225        callid = _ipc_call_async(phoneid, &call->u.msg.data);
    220226
    221         ipc_finish_async(callid, phoneid, call);
     227        ipc_finish_async(callid, phoneid, call, can_preempt);
    222228}
    223229
     
    277283
    278284                futex_up(&async_futex);
    279                 psthread_add_ready(call->ptid);
     285                if (call->ptid)
     286                        psthread_add_ready(call->ptid);
    280287               
    281288                if (callid == IPC_CALLRET_FATAL) {
     
    431438}
    432439
    433 
    434 /** Open shared memory connection over specified phoneid
    435  *
    436  *
    437  * Allocate as_area, notify the other side about our intention
    438  * to open the connection
    439  *
    440  * @return Connection id identifying this connection
    441  */
    442 //int ipc_dgr_open(int pohoneid, size_t bufsize)
    443 //{
    444         /* Find new file descriptor in local descriptor table */
    445         /* Create AS_area, initialize structures */
    446         /* Send AS to other side, handle error states */
    447 
    448 //}
    449 /*
    450 void ipc_dgr_close(int cid)
    451 {
    452 }
    453 
    454 void * ipc_dgr_alloc(int cid, size_t size)
    455 {
    456 }
    457 
    458 void ipc_dgr_free(int cid, void *area)
    459 {
    460 
    461 }
    462 
    463 int ipc_dgr_send(int cid, void *area)
    464 {
    465 }
    466 
    467 
    468 int ipc_dgr_send_data(int cid, void *data, size_t size)
    469 {
    470 }
    471 
    472 */
     440/* Primitive functions for simple communication */
     441void send_call_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
     442                 ipcarg_t arg2, ipcarg_t arg3)
     443{
     444        ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL, 1);
     445}
     446
     447void send_call_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2)
     448{
     449        ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL, 1);
     450}
     451
     452void nsend_call_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
     453                  ipcarg_t arg2, ipcarg_t arg3)
     454{
     455        ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL, 0);
     456}
     457
     458void nsend_call_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2)
     459{
     460        ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL, 0);
     461}
     462
Note: See TracChangeset for help on using the changeset viewer.