Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2187 → Rev 2188

/trunk/uspace/libc/include/unistd.h
44,8 → 44,9
extern ssize_t write(int fd, const void * buf, size_t count);
extern ssize_t read(int fd, void * buf, size_t count);
extern void _exit(int status);
void *sbrk(ssize_t incr);
void usleep(unsigned long usec);
extern void *sbrk(ssize_t incr);
extern void usleep(unsigned long usec);
extern unsigned int sleep(unsigned int seconds);
 
#endif
 
/trunk/uspace/libc/include/thread.h
44,6 → 44,9
 
extern int thread_create(void (* function)(void *arg), void *arg, char *name);
extern void thread_exit(int status);
extern void thread_detach(int thread);
extern int thread_join(int thread);
extern int thread_get_id(void);
extern tcb_t * __make_tls(void);
extern tcb_t * __alloc_tls(void **data, size_t size);
extern void __free_tls(tcb_t *);
/trunk/uspace/libc/generic/time.c
108,14 → 108,31
return 0;
}
 
/** Wait unconditionally for specified microseconds */
/** Wait unconditionally for specified number of microseconds */
void usleep(unsigned long usec)
{
atomic_t futex = FUTEX_INITIALIZER;
 
futex_initialize(&futex,0);
futex_initialize(&futex, 0);
futex_down_timeout(&futex, usec, 0);
}
 
/** Wait unconditionally for specified number of seconds */
unsigned int sleep(unsigned int seconds)
{
atomic_t futex = FUTEX_INITIALIZER;
 
futex_initialize(&futex, 0);
/* Sleep in 1000 second steps to support
full argument range */
while (seconds > 0) {
unsigned int period = (seconds > 1000) ? 1000 : seconds;
futex_down_timeout(&futex, period * 1000000, 0);
seconds -= period;
}
}
 
/** @}
*/
/trunk/uspace/libc/generic/thread.c
160,5 → 160,36
__SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status);
}
 
/** Detach thread.
*
* Currently not implemented.
*
* @param thread TID.
*/
void thread_detach(int thread)
{
}
 
/** Join thread.
*
* Currently not implemented.
*
* @param thread TID.
*
* @return Thread exit status.
*/
int thread_join(int thread)
{
}
 
/** Get current thread ID.
*
* @return Current thread ID.
*/
int thread_get_id(void)
{
return __SYSCALL0(SYS_THREAD_GET_ID);
}
 
/** @}
*/