Rev 1360 | Rev 1392 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1360 | Rev 1365 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include <errno.h> |
32 | #include <errno.h> |
33 | #include <libadt/list.h> |
33 | #include <libadt/list.h> |
34 | #include <stdio.h> |
34 | #include <stdio.h> |
35 | #include <unistd.h> |
35 | #include <unistd.h> |
36 | #include <futex.h> |
36 | #include <futex.h> |
- | 37 | #include <kernel/synch/synch.h> |
|
37 | 38 | ||
38 | /** Structure used for keeping track of sent async msgs |
39 | /** Structure used for keeping track of sent async msgs |
39 | * and queing unsent msgs |
40 | * and queing unsent msgs |
40 | * |
41 | * |
41 | */ |
42 | */ |
Line 249... | Line 250... | ||
249 | futex_up(&ipc_futex); |
250 | futex_up(&ipc_futex); |
250 | printf("Received unidentified answer: %P!!!\n", callid); |
251 | printf("Received unidentified answer: %P!!!\n", callid); |
251 | } |
252 | } |
252 | 253 | ||
253 | 254 | ||
254 | /** Wait for IPC call and return |
255 | /** Unconditionally wait for an IPC call. |
255 | * |
256 | * |
256 | * - dispatch ASYNC reoutines in the background |
257 | * - dispatch ASYNC reoutines in the background |
257 | * @param data Space where the message is stored |
258 | * @param call Space where the message is stored |
258 | * @return Callid or 0 if nothing available and started with |
259 | * @return Callid of the answer. |
259 | * IPC_WAIT_NONBLOCKING |
- | |
260 | */ |
260 | */ |
261 | ipc_callid_t ipc_wait_for_call(ipc_call_t *call, int flags) |
261 | ipc_callid_t ipc_wait_for_call(ipc_call_t *call) |
262 | { |
262 | { |
263 | ipc_callid_t callid; |
263 | ipc_callid_t callid; |
264 | 264 | ||
265 | do { |
265 | do { |
266 | try_dispatch_queued_calls(); |
266 | try_dispatch_queued_calls(); |
267 | 267 | ||
- | 268 | callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING); |
|
- | 269 | /* Handle received answers */ |
|
- | 270 | if (callid & IPC_CALLID_ANSWERED) |
|
- | 271 | handle_answer(callid, call); |
|
- | 272 | } while (callid & IPC_CALLID_ANSWERED); |
|
- | 273 | ||
- | 274 | return callid; |
|
- | 275 | } |
|
- | 276 | ||
- | 277 | /** Wait some time for an IPC call. |
|
- | 278 | * |
|
- | 279 | * - dispatch ASYNC reoutines in the background |
|
- | 280 | * @param call Space where the message is stored |
|
- | 281 | * @param usec Timeout in microseconds. |
|
- | 282 | * @return Callid of the answer. |
|
- | 283 | */ |
|
- | 284 | ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, uint32_t usec) |
|
- | 285 | { |
|
- | 286 | ipc_callid_t callid; |
|
- | 287 | ||
- | 288 | do { |
|
- | 289 | try_dispatch_queued_calls(); |
|
- | 290 | ||
268 | callid = __SYSCALL2(SYS_IPC_WAIT, (sysarg_t)call, flags); |
291 | callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, SYNCH_BLOCKING); |
- | 292 | /* Handle received answers */ |
|
- | 293 | if (callid & IPC_CALLID_ANSWERED) |
|
- | 294 | handle_answer(callid, call); |
|
- | 295 | } while (callid & IPC_CALLID_ANSWERED); |
|
- | 296 | ||
- | 297 | return callid; |
|
- | 298 | } |
|
- | 299 | ||
- | 300 | /** Check if there is an IPC call waiting to be picked up. |
|
- | 301 | * |
|
- | 302 | * - dispatch ASYNC reoutines in the background |
|
- | 303 | * @param call Space where the message is stored |
|
- | 304 | * @return Callid of the answer. |
|
- | 305 | */ |
|
- | 306 | ipc_callid_t ipc_trywait_for_call(ipc_call_t *call) |
|
- | 307 | { |
|
- | 308 | ipc_callid_t callid; |
|
- | 309 | ||
- | 310 | do { |
|
- | 311 | try_dispatch_queued_calls(); |
|
- | 312 | ||
- | 313 | callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t)call, SYNCH_NO_TIMEOUT, SYNCH_NON_BLOCKING); |
|
269 | /* Handle received answers */ |
314 | /* Handle received answers */ |
270 | if (callid & IPC_CALLID_ANSWERED) |
315 | if (callid & IPC_CALLID_ANSWERED) |
271 | handle_answer(callid, call); |
316 | handle_answer(callid, call); |
272 | } while (callid & IPC_CALLID_ANSWERED); |
317 | } while (callid & IPC_CALLID_ANSWERED); |
273 | 318 |