Changeset 9a99aa5 in mainline
- Timestamp:
- 2017-05-30T19:35:46Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 316795c
- Parents:
- 134e3f1
- Location:
- uspace/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril_synch.c
r134e3f1 r9a99aa5 629 629 } 630 630 631 /** Delay fibril execution for the specified number of microseconds 632 * 633 * @param usec Number of microseconds to sleep 634 */ 635 void fibril_usleep(useconds_t usec) 636 { 637 fibril_condvar_t cv; 638 fibril_mutex_t lock; 639 640 fibril_condvar_initialize(&cv); 641 fibril_mutex_initialize(&lock); 642 fibril_mutex_lock(&lock); 643 fibril_condvar_wait_timeout(&cv, &lock, usec); 644 fibril_mutex_unlock(&lock); 645 } 646 647 /** Delay fibril execution for the specified number of seconds 648 * 649 * @param sec Number of seconds to sleep 650 */ 651 void fibril_sleep(unsigned int sec) 652 { 653 /* 654 * Sleep in 1000 second steps to support 655 * full argument range 656 */ 657 658 while (sec > 0) { 659 unsigned int period = (sec > 1000) ? 1000 : sec; 660 661 fibril_usleep(period * 1000000); 662 sec -= period; 663 } 664 } 665 666 631 667 /** @} 632 668 */ -
uspace/lib/c/include/fibril_synch.h
r134e3f1 r9a99aa5 173 173 extern fibril_timer_state_t fibril_timer_clear(fibril_timer_t *); 174 174 extern fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *); 175 extern void fibril_usleep(useconds_t); 176 extern void fibril_sleep(unsigned int); 175 177 176 178 #endif -
uspace/lib/posix/source/time.c
r134e3f1 r9a99aa5 45 45 #include "posix/assert.h" 46 46 47 #include "libc/fibril_synch.h" 47 48 #include "libc/malloc.h" 48 49 #include "libc/task.h" … … 50 51 #include "libc/stdbool.h" 51 52 #include "libc/stddef.h" 52 #include "libc/thread.h"53 53 #include "libc/sys/time.h" 54 54 … … 315 315 // TODO: interruptible sleep 316 316 if (rqtp->tv_sec != 0) { 317 thread_sleep(rqtp->tv_sec);317 fibril_sleep(rqtp->tv_sec); 318 318 } 319 319 if (rqtp->tv_nsec != 0) { 320 thread_usleep(rqtp->tv_nsec / 1000);320 fibril_usleep(rqtp->tv_nsec / 1000); 321 321 } 322 322 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.