Subversion Repositories HelenOS-historic

Rev

Rev 1427 | Rev 1441 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1427 Rev 1435
Line 329... Line 329...
329
/** Endless loop dispatching incoming calls and answers */
329
/** Endless loop dispatching incoming calls and answers */
330
int async_manager()
330
int async_manager()
331
{
331
{
332
    ipc_call_t call;
332
    ipc_call_t call;
333
    ipc_callid_t callid;
333
    ipc_callid_t callid;
-
 
334
    int timeout;
334
 
335
 
335
    while (1) {
336
    while (1) {
336
        if (psthread_schedule_next_adv(PS_FROM_MANAGER)) {
337
        if (psthread_schedule_next_adv(PS_FROM_MANAGER)) {
337
            futex_up(&async_futex); /* async_futex is always held
338
            futex_up(&async_futex); /* async_futex is always held
338
                        * when entering manager thread
339
                        * when entering manager thread
339
                        */
340
                        */
340
            continue;
341
            continue;
341
        }
342
        }
-
 
343
/*
-
 
344
        if (expires)
-
 
345
            timeout = .... ;
-
 
346
        else
-
 
347
*/
-
 
348
            timeout = SYNCH_NO_TIMEOUT;
342
        callid = ipc_wait_cycle(&call,SYNCH_NO_TIMEOUT,SYNCH_BLOCKING);
349
        callid = ipc_wait_cycle(&call, timeout, SYNCH_BLOCKING);
-
 
350
 
-
 
351
        if (!callid) {
-
 
352
//          handle_expired_timeouts.......;
-
 
353
            continue;
-
 
354
        }
343
 
355
 
344
        if (callid & IPC_CALLID_ANSWERED)
356
        if (callid & IPC_CALLID_ANSWERED)
345
            continue;
357
            continue;
346
 
358
 
347
        handle_call(callid, &call);
359
        handle_call(callid, &call);
Line 402... Line 414...
402
    /* Copy data after futex_down, just in case the
414
    /* Copy data after futex_down, just in case the
403
     * call was detached
415
     * call was detached
404
     */
416
     */
405
    if (msg->dataptr)
417
    if (msg->dataptr)
406
        *msg->dataptr = *data;
418
        *msg->dataptr = *data;
407
   
419
 
-
 
420
    /* TODO: memory barrier?? */
408
    msg->done = 1;
421
    msg->done = 1;
409
    if (! msg->active) {
422
    if (! msg->active) {
410
        msg->active = 1;
423
        msg->active = 1;
411
        psthread_add_ready(msg->ptid);
424
        psthread_add_ready(msg->ptid);
412
    }
425
    }
Line 458... Line 471...
458
done:
471
done:
459
    if (retval)
472
    if (retval)
460
        *retval = msg->retval;
473
        *retval = msg->retval;
461
    free(msg);
474
    free(msg);
462
}
475
}
-
 
476
 
-
 
477
 
-
 
478
/* int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, int timeout) */
-
 
479
/* { */
-
 
480
/*  amsg_t *msg = (amsg_t *) amsgid; */
-
 
481
/*  connection_t *conn; */
-
 
482
 
-
 
483
/*  futex_down(&async_futex); */
-
 
484
/*  if (msg->done) { */
-
 
485
/*      futex_up(&async_futex); */
-
 
486
/*      goto done; */
-
 
487
/*  } */
-
 
488
 
-
 
489
/*  msg->ptid = psthread_get_id(); */
-
 
490
/*  msg->active = 0; */
-
 
491
/*  msg->expires = gettime() + timeout; */
-
 
492
/*  setup_timeouts_etc...(); */
-
 
493
 
-
 
494
/*  /\* Leave locked async_futex when entering this function *\/ */
-
 
495
/*  psthread_schedule_next_adv(PS_TO_MANAGER); */
-
 
496
/*  /\* futex is up automatically after psthread_schedule_next...*\/ */
-
 
497
 
-
 
498
/*  if (!msg->done) */
-
 
499
/*      return casy-casy; */
-
 
500
 
-
 
501
/*  /\* TODO: When memory barrier in reply_received, we can skip this *\/ */
-
 
502
/*  futex_down(&async_futex); */
-
 
503
/*  futex_up(&async_futex); */
-
 
504
/* done: */
-
 
505
   
-
 
506
/*  if (retval) */
-
 
507
/*      *retval = msg->retval; */
-
 
508
/*  free(msg); */
-
 
509
/* } */
-
 
510