Changes in uspace/lib/c/generic/ipc.c [d7978525:c170438] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ipc.c
rd7978525 rc170438 81 81 LIST_INITIALIZE(queued_calls); 82 82 83 static atomic_t ipc_futex = FUTEX_INITIALIZER;83 static futex_t ipc_futex = FUTEX_INITIALIZER; 84 84 85 85 /** Send asynchronous message via syscall. … … 96 96 } 97 97 98 /** Prolog for ipc_call_async_*() functions.98 /** Prologue for ipc_call_async_*() functions. 99 99 * 100 100 * @param private Argument for the answer/error callback. … … 122 122 } 123 123 124 /** Epilog for ipc_call_async_*() functions.124 /** Epilogue for ipc_call_async_*() functions. 125 125 * 126 126 * @param callid Value returned by the SYS_IPC_CALL_ASYNC_* syscall. 127 127 * @param phoneid Phone handle through which the call was made. 128 128 * @param call Structure returned by ipc_prepare_async(). 129 * @param can_preempt If true, the current fibril can be preempted130 * in this call.131 *132 129 */ 133 130 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, 134 async_call_t *call , bool can_preempt)131 async_call_t *call) 135 132 { 136 133 if (!call) { 137 134 /* Nothing to do regardless if failed or not */ 138 futex_u p(&ipc_futex);135 futex_unlock(&ipc_futex); 139 136 return; 140 137 } 141 138 142 139 if (callid == (ipc_callid_t) IPC_CALLRET_FATAL) { 143 futex_u p(&ipc_futex);140 futex_unlock(&ipc_futex); 144 141 145 142 /* Call asynchronous handler with error code */ … … 152 149 153 150 if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) { 154 futex_u p(&ipc_futex);151 futex_unlock(&ipc_futex); 155 152 156 153 call->u.msg.phoneid = phoneid; … … 159 156 list_append(&call->list, &queued_calls); 160 157 161 if (can_preempt) { 162 call->fid = fibril_get_id(); 163 fibril_switch(FIBRIL_TO_MANAGER); 164 /* Async futex unlocked by previous call */ 165 } else { 166 call->fid = 0; 167 futex_up(&async_futex); 168 } 158 call->fid = fibril_get_id(); 159 fibril_switch(FIBRIL_TO_MANAGER); 160 /* Async futex unlocked by previous call */ 169 161 170 162 return; … … 175 167 /* Add call to the list of dispatched calls */ 176 168 list_append(&call->list, &dispatched_calls); 177 futex_u p(&ipc_futex);169 futex_unlock(&ipc_futex); 178 170 } 179 171 … … 197 189 * @param private Argument to be passed to the answer/error callback. 198 190 * @param callback Answer or error callback. 199 * @param can_preempt If true, the current fibril will be preempted in200 * case the kernel temporarily refuses to accept more201 * asynchronous calls.202 *203 191 */ 204 192 void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1, 205 193 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private, 206 ipc_async_callback_t callback , bool can_preempt)194 ipc_async_callback_t callback) 207 195 { 208 196 async_call_t *call = NULL; … … 219 207 */ 220 208 221 futex_ down(&ipc_futex);209 futex_lock(&ipc_futex); 222 210 ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, 223 211 imethod, arg1, arg2, arg3, arg4); … … 226 214 if (!call) { 227 215 call = ipc_prepare_async(private, callback); 228 if (!call) 216 if (!call) { 217 futex_unlock(&ipc_futex); 229 218 return; 219 } 230 220 } 231 221 … … 244 234 } 245 235 246 ipc_finish_async(callid, phoneid, call , can_preempt);236 ipc_finish_async(callid, phoneid, call); 247 237 } 248 238 … … 264 254 * @param private Argument to be passed to the answer/error callback. 265 255 * @param callback Answer or error callback. 266 * @param can_preempt If true, the current fibril will be preempted in267 * case the kernel temporarily refuses to accept more268 * asynchronous calls.269 *270 256 */ 271 257 void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, 272 258 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private, 273 ipc_async_callback_t callback , bool can_preempt)259 ipc_async_callback_t callback) 274 260 { 275 261 async_call_t *call = ipc_prepare_async(private, callback); … … 289 275 */ 290 276 291 futex_ down(&ipc_futex);277 futex_lock(&ipc_futex); 292 278 ipc_callid_t callid = 293 279 ipc_call_async_internal(phoneid, &call->u.msg.data); 294 280 295 ipc_finish_async(callid, phoneid, call , can_preempt);281 ipc_finish_async(callid, phoneid, call); 296 282 } 297 283 … … 373 359 futex_up(&async_futex); 374 360 375 if (call->fid)376 361 assert(call->fid); 362 fibril_add_ready(call->fid); 377 363 378 364 if (callid == (ipc_callid_t) IPC_CALLRET_FATAL) { … … 384 370 call->u.callid = callid; 385 371 386 futex_ down(&ipc_futex);372 futex_lock(&ipc_futex); 387 373 list_append(&call->list, &dispatched_calls); 388 futex_u p(&ipc_futex);374 futex_unlock(&ipc_futex); 389 375 } 390 376 … … 412 398 callid &= ~IPC_CALLID_ANSWERED; 413 399 414 futex_ down(&ipc_futex);400 futex_lock(&ipc_futex); 415 401 416 402 link_t *item; … … 423 409 list_remove(&call->list); 424 410 425 futex_u p(&ipc_futex);411 futex_unlock(&ipc_futex); 426 412 427 413 if (call->callback) … … 434 420 } 435 421 436 futex_u p(&ipc_futex);422 futex_unlock(&ipc_futex); 437 423 } 438 424
Note:
See TracChangeset
for help on using the changeset viewer.