Changeset 085bd54 in mainline for libc/generic/async.c
- Timestamp:
- 2006-06-06T15:16:08Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63bb83e
- Parents:
- d7eafd8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/async.c
rd7eafd8 r085bd54 135 135 } connection_t; 136 136 137 137 /** Identifier of incoming connection handled by current thread */ 138 138 __thread connection_t *PS_connection; 139 /** If true, it is forbidden to use async_req functions and 140 * all preemption is disabled */ 141 __thread int in_interrupt_handler; 139 142 140 143 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); … … 226 229 227 230 wd->timedout = 0; 231 wd->inlist = 1; 228 232 229 233 tmp = timeout_list.next; … … 295 299 conn = PS_connection; 296 300 297 if (usecs < 0) /* TODO: let it get through the ipc_call once */298 return 0;299 300 301 futex_down(&async_futex); 301 302 … … 308 309 /* If nothing in queue, wait until something appears */ 309 310 while (list_empty(&conn->msg_queue)) { 310 if (usecs) { 311 conn->wdata.inlist = 1; 311 if (usecs) 312 312 insert_timeout(&conn->wdata); 313 } 313 314 314 conn->wdata.active = 0; 315 315 psthread_schedule_next_adv(PS_TO_MANAGER); … … 363 363 PS_connection = (connection_t *)arg; 364 364 PS_connection->cthread(PS_connection->callid, &PS_connection->call); 365 366 365 /* Remove myself from connection hash table */ 367 366 futex_down(&async_futex); … … 436 435 switch (IPC_GET_METHOD(*call)) { 437 436 case IPC_M_INTERRUPT: 437 in_interrupt_handler = 1; 438 438 (*interrupt_received)(callid,call); 439 in_interrupt_handler = 0; 439 440 return; 440 441 case IPC_M_CONNECT_ME_TO: … … 486 487 487 488 /** Endless loop dispatching incoming calls and answers */ 488 int async_manager(void)489 static int async_manager_worker(void) 489 490 { 490 491 ipc_call_t call; … … 522 523 } 523 524 524 if (callid & IPC_CALLID_ANSWERED) 525 if (callid & IPC_CALLID_ANSWERED) { 525 526 continue; 527 } 526 528 527 529 handle_call(callid, &call); … … 538 540 static int async_manager_thread(void *arg) 539 541 { 542 in_interrupt_handler = 0; // TODO: Handle TLS better 540 543 futex_up(&async_futex); /* async_futex is always locked when entering 541 544 * manager */ 542 async_manager ();545 async_manager_worker(); 543 546 } 544 547 … … 608 611 amsg_t *msg; 609 612 613 if (in_interrupt_handler) { 614 printf("Cannot send asynchronou request in interrupt handler.\n"); 615 _exit(1); 616 } 617 610 618 msg = malloc(sizeof(*msg)); 611 619 msg->done = 0; … … 628 636 { 629 637 amsg_t *msg; 638 639 if (in_interrupt_handler) { 640 printf("Cannot send asynchronou request in interrupt handler.\n"); 641 _exit(1); 642 } 630 643 631 644 msg = malloc(sizeof(*msg)); … … 699 712 msg->wdata.ptid = psthread_get_id(); 700 713 msg->wdata.active = 0; 701 msg->wdata.inlist = 1;702 703 714 insert_timeout(&msg->wdata); 704 715 … … 726 737 amsg_t *msg; 727 738 739 if (in_interrupt_handler) { 740 printf("Cannot call async_usleep in interrupt handler.\n"); 741 _exit(1); 742 } 743 728 744 msg = malloc(sizeof(*msg)); 729 745 if (!msg) … … 731 747 732 748 msg->wdata.ptid = psthread_get_id(); 733 msg->wdata.inlist = 1;734 749 msg->wdata.active = 0; 735 750 … … 757 772 interrupt_received = conn; 758 773 } 774 775 /* Primitive functions for simple communication */ 776 void async_msg_3(int phoneid, ipcarg_t method, ipcarg_t arg1, 777 ipcarg_t arg2, ipcarg_t arg3) 778 { 779 ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL, !in_interrupt_handler); 780 } 781 782 void async_msg_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2) 783 { 784 ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL, !in_interrupt_handler); 785 }
Note:
See TracChangeset
for help on using the changeset viewer.