Changeset fc42b28 in mainline


Ignore:
Timestamp:
2006-05-31T15:08:41Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
440cff5
Parents:
3f695aad
Message:

Added asynchronous waiting on ipc_async_send, when kernel limits
are reached. It works better in test_time.

Location:
libc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/async.c

    r3f695aad rfc42b28  
    9494#include <arch/barrier.h>
    9595
    96 static atomic_t async_futex = FUTEX_INITIALIZER;
     96atomic_t async_futex = FUTEX_INITIALIZER;
    9797static hash_table_t conn_hash_table;
    9898static LIST_INITIALIZE(timeout_list);
  • libc/generic/ipc.c

    r3f695aad rfc42b28  
    3636#include <futex.h>
    3737#include <kernel/synch/synch.h>
     38#include <async.h>
     39#include <psthread.h>
    3840
    3941/** Structure used for keeping track of sent async msgs
     
    5355                } msg;
    5456        }u;
     57        pstid_t ptid;   /**< Thread waiting for sending this msg */
    5558} async_call_t;
    5659
    5760LIST_INITIALIZE(dispatched_calls);
    58 LIST_INITIALIZE(queued_calls);
     61
     62/* queued_calls is protcted by async_futex, because if the
     63 * call cannot be sent into kernel, async framework is used
     64 * automatically
     65 */
     66LIST_INITIALIZE(queued_calls); /**< List of async calls that were not accepted
     67                                *   by kernel */
    5968
    6069static atomic_t ipc_futex = FUTEX_INITIALIZER;
     
    125134                return;
    126135        }
    127                
     136
     137        call->callback = callback;
     138        call->private = private;
     139
     140        /* We need to make sure that we get callid before
     141         * another thread accesses the queue again */
     142        futex_down(&ipc_futex);
    128143        callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2);
    129144        if (callid == IPC_CALLRET_FATAL) {
     145                futex_up(&ipc_futex);
    130146                /* Call asynchronous handler with error code */
    131147                if (callback)
     
    135151        }
    136152
    137         call->callback = callback;
    138         call->private = private;
    139 
    140153        if (callid == IPC_CALLRET_TEMPORARY) {
    141                 /* Add asynchronous call to queue of non-dispatched async calls */
     154                futex_up(&ipc_futex);
     155
    142156                call->u.msg.phoneid = phoneid;
    143157                IPC_SET_METHOD(call->u.msg.data, method);
    144158                IPC_SET_ARG1(call->u.msg.data, arg1);
    145159                IPC_SET_ARG2(call->u.msg.data, arg2);
    146                
    147                 futex_down(&ipc_futex);
     160
     161                call->ptid = psthread_get_id();
     162                futex_down(&async_futex);
    148163                list_append(&call->list, &queued_calls);
    149                 futex_up(&ipc_futex);
     164
     165                psthread_schedule_next_adv(PS_TO_MANAGER);
     166                /* Async futex unlocked by previous call */
    150167                return;
    151168        }
    152169        call->u.callid = callid;
    153170        /* Add call to list of dispatched calls */
    154         futex_down(&ipc_futex);
    155171        list_append(&call->list, &dispatched_calls);
    156172        futex_up(&ipc_futex);
     
    195211        ipc_callid_t callid;
    196212
    197         futex_down(&ipc_futex);
     213        /* TODO: integrate intelligently ipc_futex, so that it
     214         * is locked during ipc_call_async, until it is added
     215         * to dispatched_calls
     216         */
     217        futex_down(&async_futex);
    198218        while (!list_empty(&queued_calls)) {
    199219                call = list_get_instance(queued_calls.next, async_call_t,
     
    202222                callid = _ipc_call_async(call->u.msg.phoneid,
    203223                                         &call->u.msg.data);
    204                 if (callid == IPC_CALLRET_TEMPORARY)
     224                if (callid == IPC_CALLRET_TEMPORARY) {
    205225                        break;
     226                }
    206227                list_remove(&call->list);
    207228
     229                futex_up(&async_futex);
     230                psthread_add_ready(call->ptid);
     231               
    208232                if (callid == IPC_CALLRET_FATAL) {
    209                         futex_up(&ipc_futex);
    210233                        if (call->callback)
    211234                                call->callback(call->private, ENOENT, NULL);
    212235                        free(call);
    213                         futex_down(&ipc_futex);
    214236                } else {
    215237                        call->u.callid = callid;
     238                        futex_down(&ipc_futex);
    216239                        list_append(&call->list, &dispatched_calls);
     240                        futex_up(&ipc_futex);
    217241                }
    218         }
    219         futex_up(&ipc_futex);
     242                futex_down(&async_futex);
     243        }
     244        futex_up(&async_futex);
    220245}
    221246
     
    265290        ipc_callid_t callid;
    266291
    267         try_dispatch_queued_calls();
    268        
    269292        callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
    270293        /* Handle received answers */
    271         if (callid & IPC_CALLID_ANSWERED)
     294        if (callid & IPC_CALLID_ANSWERED) {
    272295                handle_answer(callid, call);
     296                try_dispatch_queued_calls();
     297        }
    273298
    274299        return callid;
  • libc/include/async.h

    r3f695aad rfc42b28  
    55#include <psthread.h>
    66#include <sys/time.h>
     7#include <atomic.h>
    78
    89typedef ipc_callid_t aid_t;
     
    2728void interrupt_received(ipc_call_t *call)  __attribute__((weak));
    2829
     30
     31extern atomic_t async_futex;
     32
    2933#endif
Note: See TracChangeset for help on using the changeset viewer.