Changeset 6b21292 in mainline for uspace/lib/libc/generic/async.c


Ignore:
Timestamp:
2008-12-30T19:34:23Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3ad953c
Parents:
1c1002a
Message:

support for sending asynchronous messages (without preemption) in interrupt notification handler
any potential synchronization problems should be solved properly in the user code, not by an unconditional termination

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/async.c

    r1c1002a r6b21292  
    484484        connection_t *conn;
    485485        unsigned long key;
    486 
     486       
    487487        conn = malloc(sizeof(*conn));
    488488        if (!conn) {
     
    499499        conn->wdata.active = 1; /* We will activate the fibril ASAP */
    500500        conn->cfibril = cfibril;
    501 
     501       
    502502        conn->wdata.fid = fibril_create(connection_fibril, conn);
    503503        if (!conn->wdata.fid) {
     
    507507                return NULL;
    508508        }
     509       
    509510        /* Add connection to the connection hash table */
    510511        key = conn->in_phone_hash;
     
    512513        hash_table_insert(&conn_hash_table, &key, &conn->link);
    513514        futex_up(&async_futex);
    514 
     515       
    515516        fibril_add_ready(conn->wdata.fid);
    516 
     517       
    517518        return conn->wdata.fid;
    518519}
     
    525526 * @param callid        Hash of the incoming call.
    526527 * @param call          Data of the incoming call.
     528 *
    527529 */
    528530static void handle_call(ipc_callid_t callid, ipc_call_t *call)
     
    534536                _in_interrupt_handler = 0;
    535537                return;
    536         }               
    537 
     538        }
     539       
    538540        switch (IPC_GET_METHOD(*call)) {
    539541        case IPC_M_CONNECT_ME_TO:
     
    543545                return;
    544546        }
    545 
     547       
    546548        /* Try to route the call through the connection hash table */
    547549        if (route_call(callid, call))
    548550                return;
    549 
     551       
    550552        /* Unknown call from unknown phone - hang it up */
    551553        ipc_answer_0(callid, EHANGUP);
     
    740742{
    741743        amsg_t *msg;
    742 
    743         if (_in_interrupt_handler) {
    744                 printf("Cannot send asynchronous request in interrupt "
    745                     "handler.\n");
    746                 _exit(1);
    747         }
    748 
     744       
    749745        msg = malloc(sizeof(*msg));
    750746        msg->done = 0;
    751747        msg->dataptr = dataptr;
    752 
     748       
    753749        /* We may sleep in the next method, but it will use its own mechanism */
    754750        msg->wdata.active = 1;
    755751                               
    756752        ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, msg,
    757             reply_received, 1);
    758 
     753            reply_received, !_in_interrupt_handler);
     754       
    759755        return (aid_t) msg;
    760756}
     
    782778{
    783779        amsg_t *msg;
    784 
    785         if (_in_interrupt_handler) {
    786                 printf("Cannot send asynchronous request in interrupt "
    787                     "handler.\n");
    788                 _exit(1);
    789         }
    790 
     780       
    791781        msg = malloc(sizeof(*msg));
    792782        msg->done = 0;
    793783        msg->dataptr = dataptr;
    794 
     784       
    795785        /* We may sleep in next method, but it will use its own mechanism */
    796786        msg->wdata.active = 1;
    797 
     787       
    798788        ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, msg,
    799             reply_received, 1);
    800 
     789            reply_received, !_in_interrupt_handler);
     790       
    801791        return (aid_t) msg;
    802792}
     
    885875        amsg_t *msg;
    886876       
    887         if (_in_interrupt_handler) {
    888                 printf("Cannot call async_usleep in interrupt handler.\n");
    889                 _exit(1);
    890         }
    891 
    892877        msg = malloc(sizeof(*msg));
    893878        if (!msg)
    894879                return;
    895 
     880       
    896881        msg->wdata.fid = fibril_get_id();
    897882        msg->wdata.active = 0;
    898 
     883       
    899884        gettimeofday(&msg->wdata.expires, NULL);
    900885        tv_add(&msg->wdata.expires, timeout);
    901 
     886       
    902887        futex_down(&async_futex);
    903888        insert_timeout(&msg->wdata);
Note: See TracChangeset for help on using the changeset viewer.