Changeset bd41ac52 in mainline for uspace/lib/c/generic/thread/fibril.c
- Timestamp:
- 2018-08-25T22:21:25Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cca80a2
- Parents:
- e2625b1a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/thread/fibril.c
re2625b1a rbd41ac52 60 60 typedef struct { 61 61 link_t link; 62 struct time valexpires;62 struct timespec expires; 63 63 fibril_event_t *event; 64 64 } _timeout_t; … … 142 142 } 143 143 144 static inline errno_t _ready_down(const struct time val*expires)144 static inline errno_t _ready_down(const struct timespec *expires) 145 145 { 146 146 if (multithreaded) … … 253 253 } 254 254 255 static errno_t _ipc_wait(ipc_call_t *call, const struct time val*expires)255 static errno_t _ipc_wait(ipc_call_t *call, const struct timespec *expires) 256 256 { 257 257 if (!expires) … … 261 261 return ipc_wait(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING); 262 262 263 struct time valnow;263 struct timespec now; 264 264 getuptime(&now); 265 265 266 if (t v_gteq(&now, expires))266 if (ts_gteq(&now, expires)) 267 267 return ipc_wait(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING); 268 268 269 return ipc_wait(call, tv_sub_diff(expires, &now), SYNCH_FLAGS_NONE); 269 return ipc_wait(call, NSEC2USEC(ts_sub_diff(expires, &now)), 270 SYNCH_FLAGS_NONE); 270 271 } 271 272 … … 275 276 * wait after new ready fibrils are added. 276 277 */ 277 static fibril_t *_ready_list_pop(const struct time val*expires, bool locked)278 static fibril_t *_ready_list_pop(const struct timespec *expires, bool locked) 278 279 { 279 280 if (locked) { … … 370 371 static fibril_t *_ready_list_pop_nonblocking(bool locked) 371 372 { 372 struct time val tv = { .tv_sec = 0, .tv_usec = 0 };373 struct timespec tv = { .tv_sec = 0, .tv_nsec = 0 }; 373 374 return _ready_list_pop(&tv, locked); 374 375 } … … 393 394 394 395 /* Blocks the current fibril until an IPC call arrives. */ 395 static errno_t _wait_ipc(ipc_call_t *call, const struct time val*expires)396 static errno_t _wait_ipc(ipc_call_t *call, const struct timespec *expires) 396 397 { 397 398 futex_assert_is_not_locked(&fibril_futex); … … 430 431 431 432 /** Fire all timeouts that expired. */ 432 static struct time val *_handle_expired_timeouts(struct timeval*next_timeout)433 { 434 struct time val tv;435 getuptime(&t v);433 static struct timespec *_handle_expired_timeouts(struct timespec *next_timeout) 434 { 435 struct timespec ts; 436 getuptime(&ts); 436 437 437 438 futex_lock(&fibril_futex); … … 441 442 _timeout_t *to = list_get_instance(cur, _timeout_t, link); 442 443 443 if (t v_gt(&to->expires, &tv)) {444 if (ts_gt(&to->expires, &ts)) { 444 445 *next_timeout = to->expires; 445 446 futex_unlock(&fibril_futex); … … 535 536 (void) arg; 536 537 537 struct time valnext_timeout;538 struct timespec next_timeout; 538 539 while (true) { 539 struct time val*to = _handle_expired_timeouts(&next_timeout);540 struct timespec *to = _handle_expired_timeouts(&next_timeout); 540 541 fibril_t *f = _ready_list_pop(to, false); 541 542 if (f) { … … 615 616 _timeout_t *cur = list_get_instance(tmp, _timeout_t, link); 616 617 617 if (t v_gteq(&cur->expires, &timeout->expires))618 if (ts_gteq(&cur->expires, &timeout->expires)) 618 619 break; 619 620 … … 634 635 * @return ETIMEOUT if timed out. EOK otherwise. 635 636 */ 636 errno_t fibril_wait_timeout(fibril_event_t *event, const struct timeval *expires) 637 errno_t fibril_wait_timeout(fibril_event_t *event, 638 const struct timespec *expires) 637 639 { 638 640 assert(fibril_self()->rmutex_locks == 0); … … 889 891 } 890 892 891 void fibril_usleep( suseconds_t timeout)892 { 893 struct time valexpires;893 void fibril_usleep(usec_t timeout) 894 { 895 struct timespec expires; 894 896 getuptime(&expires); 895 t v_add_diff(&expires, timeout);897 ts_add_diff(&expires, USEC2NSEC(timeout)); 896 898 897 899 fibril_event_t event = FIBRIL_EVENT_INIT; … … 899 901 } 900 902 901 void fibril_sleep( unsigned int sec)902 { 903 struct time valexpires;903 void fibril_sleep(sec_t sec) 904 { 905 struct timespec expires; 904 906 getuptime(&expires); 905 907 expires.tv_sec += sec; … … 916 918 } 917 919 918 errno_t fibril_ipc_wait(ipc_call_t *call, const struct time val*expires)920 errno_t fibril_ipc_wait(ipc_call_t *call, const struct timespec *expires) 919 921 { 920 922 return _wait_ipc(call, expires);
Note:
See TracChangeset
for help on using the changeset viewer.