Changeset 44c6d88d in mainline for libc/generic/async.c
- Timestamp:
- 2006-05-30T17:23:33Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eaf34f7
- Parents:
- 79460ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/async.c
r79460ae r44c6d88d 270 270 } 271 271 272 /** Function that gets created on interrupt receival 273 * 274 * This function is defined as a weak symbol - to be redefined in 275 * user code. 276 */ 277 void interrupt_received(ipc_call_t *call) 278 { 279 } 280 281 272 282 /** Wrapper for client connection thread 273 283 * … … 309 319 * threads. 310 320 * 321 * @param in_phone_hash Identification of the incoming connection 311 322 * @param callid Callid of the IPC_M_CONNECT_ME_TO packet 312 323 * @param call Call data of the opening packet … … 315 326 * @return New thread id 316 327 */ 317 pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call, 328 pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, 329 ipc_call_t *call, 318 330 void (*cthread)(ipc_callid_t,ipc_call_t *)) 319 331 { … … 327 339 return NULL; 328 340 } 329 conn->in_phone_hash = IPC_GET_ARG3(*call);341 conn->in_phone_hash = in_phone_hash; 330 342 list_initialize(&conn->msg_queue); 331 343 conn->ptid = psthread_create(connection_thread, conn); … … 354 366 static void handle_call(ipc_callid_t callid, ipc_call_t *call) 355 367 { 368 /* Unrouted call - do some default behaviour */ 369 switch (IPC_GET_METHOD(*call)) { 370 case IPC_M_INTERRUPT: 371 interrupt_received(call); 372 return; 373 case IPC_M_CONNECT_ME_TO: 374 /* Open new connection with thread etc. */ 375 async_new_connection(IPC_GET_ARG3(*call), callid, call, client_connection); 376 return; 377 } 378 379 /* Try to route call through connection tables */ 356 380 if (route_call(callid, call)) 357 381 return; 358 382 359 switch (IPC_GET_METHOD(*call)) { 360 case IPC_M_INTERRUPT: 361 break; 362 case IPC_M_CONNECT_ME_TO: 363 /* Open new connection with thread etc. */ 364 async_new_connection(callid, call, client_connection); 365 break; 366 default: 367 ipc_answer_fast(callid, EHANGUP, 0, 0); 368 } 383 /* Unknown call from unknown phone - hang it up */ 384 ipc_answer_fast(callid, EHANGUP, 0, 0); 369 385 } 370 386 … … 622 638 } 623 639 640 /** Wait specified time, but in the meantime handle incoming events 641 * 642 * @param timeout Time in microseconds to wait 643 */ 644 void async_usleep(suseconds_t timeout) 645 { 646 amsg_t *msg; 647 648 msg = malloc(sizeof(*msg)); 649 if (!msg) 650 return; 651 652 msg->ptid = psthread_get_id(); 653 msg->active = 0; 654 msg->has_timeout = 1; 655 656 gettimeofday(&msg->expires, NULL); 657 tv_add(&msg->expires, timeout); 658 659 futex_down(&async_futex); 660 insert_timeout(msg); 661 /* Leave locked async_futex when entering this function */ 662 psthread_schedule_next_adv(PS_TO_MANAGER); 663 /* futex is up automatically after psthread_schedule_next...*/ 664 free(msg); 665 }
Note:
See TracChangeset
for help on using the changeset viewer.