Rev 2479 | Rev 2490 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2479 | Rev 2482 | ||
|---|---|---|---|
| Line 47... | Line 47... | ||
| 47 | #include <stdio.h> |
47 | #include <stdio.h> |
| 48 | #include <unistd.h> |
48 | #include <unistd.h> |
| 49 | #include <futex.h> |
49 | #include <futex.h> |
| 50 | #include <kernel/synch/synch.h> |
50 | #include <kernel/synch/synch.h> |
| 51 | #include <async.h> |
51 | #include <async.h> |
| 52 | #include <psthread.h> |
52 | #include <fibril.h> |
| 53 | 53 | ||
| 54 | /** Structure used for keeping track of sent asynchronous calls and queing |
54 | /** Structure used for keeping track of sent asynchronous calls and queing |
| 55 | * unsent calls. |
55 | * unsent calls. |
| 56 | */ |
56 | */ |
| 57 | typedef struct { |
57 | typedef struct { |
| Line 64... | Line 64... | ||
| 64 | struct { |
64 | struct { |
| 65 | ipc_call_t data; |
65 | ipc_call_t data; |
| 66 | int phoneid; |
66 | int phoneid; |
| 67 | } msg; |
67 | } msg; |
| 68 | } u; |
68 | } u; |
| 69 | pstid_t ptid; /**< Pseudothread waiting for sending this call. */ |
69 | fid_t fid; /**< Fibril waiting for sending this call. */ |
| 70 | } async_call_t; |
70 | } async_call_t; |
| 71 | 71 | ||
| 72 | LIST_INITIALIZE(dispatched_calls); |
72 | LIST_INITIALIZE(dispatched_calls); |
| 73 | 73 | ||
| 74 | /** List of asynchronous calls that were not accepted by kernel. |
74 | /** List of asynchronous calls that were not accepted by kernel. |
| Line 214... | Line 214... | ||
| 214 | 214 | ||
| 215 | futex_down(&async_futex); |
215 | futex_down(&async_futex); |
| 216 | list_append(&call->list, &queued_calls); |
216 | list_append(&call->list, &queued_calls); |
| 217 | 217 | ||
| 218 | if (can_preempt) { |
218 | if (can_preempt) { |
| 219 | call->ptid = psthread_get_id(); |
219 | call->fid = fibril_get_id(); |
| 220 | psthread_schedule_next_adv(PS_TO_MANAGER); |
220 | fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
| 221 | /* Async futex unlocked by previous call */ |
221 | /* Async futex unlocked by previous call */ |
| 222 | } else { |
222 | } else { |
| 223 | call->ptid = 0; |
223 | call->fid = 0; |
| 224 | futex_up(&async_futex); |
224 | futex_up(&async_futex); |
| 225 | } |
225 | } |
| 226 | return; |
226 | return; |
| 227 | } |
227 | } |
| 228 | call->u.callid = callid; |
228 | call->u.callid = callid; |
| Line 381... | Line 381... | ||
| 381 | break; |
381 | break; |
| 382 | } |
382 | } |
| 383 | list_remove(&call->list); |
383 | list_remove(&call->list); |
| 384 | 384 | ||
| 385 | futex_up(&async_futex); |
385 | futex_up(&async_futex); |
| 386 | if (call->ptid) |
386 | if (call->fid) |
| 387 | psthread_add_ready(call->ptid); |
387 | fibril_add_ready(call->fid); |
| 388 | 388 | ||
| 389 | if (callid == IPC_CALLRET_FATAL) { |
389 | if (callid == IPC_CALLRET_FATAL) { |
| 390 | if (call->callback) |
390 | if (call->callback) |
| 391 | call->callback(call->private, ENOENT, NULL); |
391 | call->callback(call->private, ENOENT, NULL); |
| 392 | free(call); |
392 | free(call); |