Changeset bd5a663 in mainline for generic/src


Ignore:
Timestamp:
2006-05-17T14:03:44Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
59477e3
Parents:
bdb9ea8
Message:

Modify ipc_wait_for_call() to support all of blocking, non-blocking and timeout operation.

Location:
generic/src/ipc
Files:
2 edited

Legend:

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

    rbdb9ea8 rbd5a663  
    3434#include <synch/spinlock.h>
    3535#include <synch/waitq.h>
     36#include <synch/synch.h>
    3637#include <ipc/ipc.h>
    3738#include <errno.h>
     
    142143
    143144        ipc_call(phone, request);
    144         ipc_wait_for_call(&sync_box, 0);
     145        ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
    145146}
    146147
     
    302303/** Wait for phone call
    303304 *
     305 * @param box Answerbox expecting the call.
     306 * @param usec Timeout in microseconds. See documentation for waitq_sleep_timeout() for
     307 *             decription of its special meaning.
     308 * @param nonblocking Blocking vs. non-blocking operation mode switch. See documentation
     309 *                    for waitq_sleep_timeout() for description of its special meaning.
    304310 * @return Recived message address
    305311 * - to distinguish between call and answer, look at call->flags
    306312 */
    307 call_t * ipc_wait_for_call(answerbox_t *box, int flags)
     313call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int nonblocking)
    308314{
    309315        call_t *request;
    310316        ipl_t ipl;
    311 
    312 restart:     
    313         if (flags & IPC_WAIT_NONBLOCKING) {
    314                 if (waitq_sleep_timeout(&box->wq,0,1) == ESYNCH_WOULD_BLOCK)
    315                         return NULL;
    316         } else
    317                 waitq_sleep(&box->wq);
     317        int rc;
     318
     319restart:
     320        rc = waitq_sleep_timeout(&box->wq, usec, nonblocking);
     321        if (SYNCH_FAILED(rc))
     322                return NULL;
    318323       
    319324        spinlock_lock(&box->lock);
     
    408413        /* Wait for all async answers to arrive */
    409414        while (atomic_get(&task->active_calls)) {
    410                 call = ipc_wait_for_call(&task->answerbox, 0);
     415                call = ipc_wait_for_call(&task->answerbox, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
    411416                ASSERT((call->flags & IPC_CALL_ANSWERED) || (call->flags & IPC_CALL_NOTIF));
    412417                ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
  • generic/src/ipc/sysipc.c

    rbdb9ea8 rbd5a663  
    469469 *
    470470 * @param calldata Pointer to buffer where the call/answer data is stored
    471  * @param flags
     471 * @param usec Timeout. See waitq_sleep_timeout() for explanation.
     472 * @param nonblocking See waitq_sleep_timeout() for explanation.
     473 *
    472474 * @return Callid, if callid & 1, then the call is answer
    473475 */
    474 __native sys_ipc_wait_for_call(ipc_data_t *calldata, __native flags)
     476__native sys_ipc_wait_for_call(ipc_data_t *calldata, __u32 usec, int nonblocking)
    475477{
    476478        call_t *call;
    477479
    478480restart:       
    479         call = ipc_wait_for_call(&TASK->answerbox, flags);
     481        call = ipc_wait_for_call(&TASK->answerbox, usec, nonblocking);
    480482        if (!call)
    481483                return 0;
Note: See TracChangeset for help on using the changeset viewer.