Changeset fc42b28 in mainline
- Timestamp:
- 2006-05-31T15:08:41Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 440cff5
- Parents:
- 3f695aad
- Location:
- libc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/async.c
r3f695aad rfc42b28 94 94 #include <arch/barrier.h> 95 95 96 staticatomic_t async_futex = FUTEX_INITIALIZER;96 atomic_t async_futex = FUTEX_INITIALIZER; 97 97 static hash_table_t conn_hash_table; 98 98 static LIST_INITIALIZE(timeout_list); -
libc/generic/ipc.c
r3f695aad rfc42b28 36 36 #include <futex.h> 37 37 #include <kernel/synch/synch.h> 38 #include <async.h> 39 #include <psthread.h> 38 40 39 41 /** Structure used for keeping track of sent async msgs … … 53 55 } msg; 54 56 }u; 57 pstid_t ptid; /**< Thread waiting for sending this msg */ 55 58 } async_call_t; 56 59 57 60 LIST_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 */ 66 LIST_INITIALIZE(queued_calls); /**< List of async calls that were not accepted 67 * by kernel */ 59 68 60 69 static atomic_t ipc_futex = FUTEX_INITIALIZER; … … 125 134 return; 126 135 } 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); 128 143 callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2); 129 144 if (callid == IPC_CALLRET_FATAL) { 145 futex_up(&ipc_futex); 130 146 /* Call asynchronous handler with error code */ 131 147 if (callback) … … 135 151 } 136 152 137 call->callback = callback;138 call->private = private;139 140 153 if (callid == IPC_CALLRET_TEMPORARY) { 141 /* Add asynchronous call to queue of non-dispatched async calls */ 154 futex_up(&ipc_futex); 155 142 156 call->u.msg.phoneid = phoneid; 143 157 IPC_SET_METHOD(call->u.msg.data, method); 144 158 IPC_SET_ARG1(call->u.msg.data, arg1); 145 159 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); 148 163 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 */ 150 167 return; 151 168 } 152 169 call->u.callid = callid; 153 170 /* Add call to list of dispatched calls */ 154 futex_down(&ipc_futex);155 171 list_append(&call->list, &dispatched_calls); 156 172 futex_up(&ipc_futex); … … 195 211 ipc_callid_t callid; 196 212 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); 198 218 while (!list_empty(&queued_calls)) { 199 219 call = list_get_instance(queued_calls.next, async_call_t, … … 202 222 callid = _ipc_call_async(call->u.msg.phoneid, 203 223 &call->u.msg.data); 204 if (callid == IPC_CALLRET_TEMPORARY) 224 if (callid == IPC_CALLRET_TEMPORARY) { 205 225 break; 226 } 206 227 list_remove(&call->list); 207 228 229 futex_up(&async_futex); 230 psthread_add_ready(call->ptid); 231 208 232 if (callid == IPC_CALLRET_FATAL) { 209 futex_up(&ipc_futex);210 233 if (call->callback) 211 234 call->callback(call->private, ENOENT, NULL); 212 235 free(call); 213 futex_down(&ipc_futex);214 236 } else { 215 237 call->u.callid = callid; 238 futex_down(&ipc_futex); 216 239 list_append(&call->list, &dispatched_calls); 240 futex_up(&ipc_futex); 217 241 } 218 } 219 futex_up(&ipc_futex); 242 futex_down(&async_futex); 243 } 244 futex_up(&async_futex); 220 245 } 221 246 … … 265 290 ipc_callid_t callid; 266 291 267 try_dispatch_queued_calls();268 269 292 callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags); 270 293 /* Handle received answers */ 271 if (callid & IPC_CALLID_ANSWERED) 294 if (callid & IPC_CALLID_ANSWERED) { 272 295 handle_answer(callid, call); 296 try_dispatch_queued_calls(); 297 } 273 298 274 299 return callid; -
libc/include/async.h
r3f695aad rfc42b28 5 5 #include <psthread.h> 6 6 #include <sys/time.h> 7 #include <atomic.h> 7 8 8 9 typedef ipc_callid_t aid_t; … … 27 28 void interrupt_received(ipc_call_t *call) __attribute__((weak)); 28 29 30 31 extern atomic_t async_futex; 32 29 33 #endif
Note:
See TracChangeset
for help on using the changeset viewer.