Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d9ece1cb in mainline for uspace/lib/libc/generic/time.c


Ignore:
Timestamp:
2009-12-01T20:08:32Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
d359e227
Parents:
d52b82ad
Message:

Introduce SYS_THREAD_USLEEP and use it to implement usleep() in uspace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/time.c

    rd52b82ad rd9ece1cb  
    4040#include <unistd.h>
    4141#include <atomic.h>
    42 #include <futex.h>
    4342#include <sysinfo.h>
    4443#include <ipc/services.h>
     44#include <libc.h>
    4545
    4646#include <sysinfo.h>
     
    191191int usleep(unsigned long usec)
    192192{
    193         atomic_t futex = FUTEX_INITIALIZER;
    194 
    195         futex_initialize(&futex, 0);
    196         futex_down_timeout(&futex, usec, 0);
     193        (void) __SYSCALL1(SYS_THREAD_USLEEP, usec);     
    197194        return 0;
    198195}
     
    201198unsigned int sleep(unsigned int seconds)
    202199{
    203         atomic_t futex = FUTEX_INITIALIZER;
    204 
    205         futex_initialize(&futex, 0);
    206        
    207200        /* Sleep in 1000 second steps to support
    208201           full argument range */
     
    210203                unsigned int period = (seconds > 1000) ? 1000 : seconds;
    211204       
    212                 futex_down_timeout(&futex, period * 1000000, 0);
     205                usleep(period * 1000000);
    213206                seconds -= period;
    214207        }
Note: See TracChangeset for help on using the changeset viewer.