Changeset f53cc81 in mainline
- Timestamp:
- 2009-10-10T21:50:22Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b6ee5b1
- Parents:
- 4f5edcf6
- Location:
- uspace/lib/libc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/async.c
r4f5edcf6 rf53cc81 235 235 static void insert_timeout(awaiter_t *wd) 236 236 { 237 wd->t imedout= false;238 wd-> inlist = true;237 wd->to_event.occurred = false; 238 wd->to_event.inlist = true; 239 239 240 240 link_t *tmp = timeout_list.next; 241 241 while (tmp != &timeout_list) { 242 awaiter_t *cur = list_get_instance(tmp, awaiter_t, link); 243 244 if (tv_gteq(&cur->expires, &wd->expires)) 242 awaiter_t *cur; 243 244 cur = list_get_instance(tmp, awaiter_t, to_event.link); 245 if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires)) 245 246 break; 246 247 247 tmp = tmp->next; 248 248 } 249 249 250 list_append(&wd-> link, tmp);250 list_append(&wd->to_event.link, tmp); 251 251 } 252 252 … … 295 295 296 296 /* If in timeout list, remove it */ 297 if (conn->wdata. inlist) {298 conn->wdata. inlist = false;299 list_remove(&conn->wdata. link);297 if (conn->wdata.to_event.inlist) { 298 conn->wdata.to_event.inlist = false; 299 list_remove(&conn->wdata.to_event.link); 300 300 } 301 301 … … 385 385 386 386 if (usecs) { 387 gettimeofday(&conn->wdata. expires, NULL);388 tv_add(&conn->wdata. expires, usecs);387 gettimeofday(&conn->wdata.to_event.expires, NULL); 388 tv_add(&conn->wdata.to_event.expires, usecs); 389 389 } else 390 conn->wdata. inlist = false;390 conn->wdata.to_event.inlist = false; 391 391 392 392 /* If nothing in queue, wait until something arrives */ … … 410 410 */ 411 411 futex_down(&async_futex); 412 if ((usecs) && (conn->wdata.t imedout)412 if ((usecs) && (conn->wdata.to_event.occurred) 413 413 && (list_empty(&conn->msg_queue))) { 414 414 /* If we timed out -> exit */ … … 605 605 link_t *cur = timeout_list.next; 606 606 while (cur != &timeout_list) { 607 awaiter_t *waiter = list_get_instance(cur, awaiter_t, link); 608 609 if (tv_gt(&waiter->expires, &tv)) 607 awaiter_t *waiter; 608 609 waiter = list_get_instance(cur, awaiter_t, to_event.link); 610 if (tv_gt(&waiter->to_event.expires, &tv)) 610 611 break; 611 612 612 613 cur = cur->next; 613 614 list_remove(&waiter-> link);615 waiter-> inlist = false;616 waiter->t imedout= true;614 615 list_remove(&waiter->to_event.link); 616 waiter->to_event.inlist = false; 617 waiter->to_event.occurred = true; 617 618 618 619 /* … … 651 652 if (!list_empty(&timeout_list)) { 652 653 awaiter_t *waiter = list_get_instance(timeout_list.next, 653 awaiter_t, link);654 awaiter_t, to_event.link); 654 655 655 656 struct timeval tv; 656 657 gettimeofday(&tv, NULL); 657 658 658 if (tv_gteq(&tv, &waiter-> expires)) {659 if (tv_gteq(&tv, &waiter->to_event.expires)) { 659 660 futex_up(&async_futex); 660 661 handle_expired_timeouts(); 661 662 continue; 662 663 } else 663 timeout = tv_sub(&waiter->expires, &tv); 664 timeout = tv_sub(&waiter->to_event.expires, 665 &tv); 664 666 } else 665 667 timeout = SYNCH_NO_TIMEOUT; … … 762 764 763 765 /* Remove message from timeout list */ 764 if (msg->wdata. inlist)765 list_remove(&msg->wdata. link);766 if (msg->wdata.to_event.inlist) 767 list_remove(&msg->wdata.to_event.link); 766 768 767 769 msg->done = true; … … 802 804 msg->dataptr = dataptr; 803 805 804 msg->wdata. inlist = false;806 msg->wdata.to_event.inlist = false; 805 807 /* We may sleep in the next method, but it will use its own mechanism */ 806 808 msg->wdata.active = true; … … 842 844 msg->dataptr = dataptr; 843 845 844 msg->wdata. inlist = false;846 msg->wdata.to_event.inlist = false; 845 847 /* We may sleep in next method, but it will use its own mechanism */ 846 848 msg->wdata.active = true; … … 871 873 msg->wdata.fid = fibril_get_id(); 872 874 msg->wdata.active = false; 873 msg->wdata. inlist = false;875 msg->wdata.to_event.inlist = false; 874 876 875 877 /* Leave the async_futex locked when entering this function */ … … 909 911 } 910 912 911 gettimeofday(&msg->wdata. expires, NULL);912 tv_add(&msg->wdata. expires, timeout);913 gettimeofday(&msg->wdata.to_event.expires, NULL); 914 tv_add(&msg->wdata.to_event.expires, timeout); 913 915 914 916 msg->wdata.fid = fibril_get_id(); … … 950 952 msg->wdata.active = false; 951 953 952 gettimeofday(&msg->wdata. expires, NULL);953 tv_add(&msg->wdata. expires, timeout);954 gettimeofday(&msg->wdata.to_event.expires, NULL); 955 tv_add(&msg->wdata.to_event.expires, timeout); 954 956 955 957 futex_down(&async_futex); -
uspace/lib/libc/include/async_priv.h
r4f5edcf6 rf53cc81 41 41 #include <bool.h> 42 42 43 /** Structures of this type represent a waiting fibril. */43 /** Structures of this type are used to track the timeout events. */ 44 44 typedef struct { 45 /** Expiration time. */46 struct timeval expires;47 48 45 /** If true, this struct is in the timeout list. */ 49 46 bool inlist; … … 52 49 link_t link; 53 50 51 /** If true, we have timed out. */ 52 bool occurred; 53 54 /** Expiration time. */ 55 struct timeval expires; 56 } to_event_t; 57 58 /** Structures of this type represent a waiting fibril. */ 59 typedef struct { 54 60 /** Identification of and link to the waiting fibril. */ 55 61 fid_t fid; … … 57 63 /** If true, this fibril is currently active. */ 58 64 bool active; 59 60 /** If true, we have timed out. */61 bool timedout;65 66 /** Timeout wait data. */ 67 to_event_t to_event; 62 68 } awaiter_t; 63 69
Note:
See TracChangeset
for help on using the changeset viewer.