- 论坛徽章:
- 0
|
以前为了让某个线程单独延时都是用的usleep/nanusleep,有人说这会让整个进程都sleep,是真的吗?man里也没说明,还有pthread_delay_np 好象linux也不支持吧
NAME
getitimer, setitimer ? get or set value of an interval timer
SYNOPSIS
#include <sys/time.h>;
int getitimer(int which, struct itimerval *value);
int setitimer(int which, const struct itimerval *value, struct itimer?\
val *ovalue);
DESCRIPTION
The system provides each process with three interval timers, each
decrementing in a distinct time domain. When any timer expires, a sig?\
nal is sent to the process, and the timer (potentially) restarts.
**************************************************************
NAME
usleep ? suspend execution for microsecond intervals
SYNOPSIS
#include <unistd.h>;
void usleep(unsigned long usec);
int usleep(unsigned long usec); /* SUSv2 */
DESCRIPTION
The usleep() function suspends execution of the calling process for
usec microseconds. The sleep may be lengthened slightly by any system
activity or by the time spent processing the call.
**************************************************************
NAME
nanosleep ? pause execution for a specified time
SYNOPSIS
#include <time.h>;
int nanosleep(const struct timespec *req, struct timespec *rem);
DESCRIPTION
nanosleep delays the execution of the program for at least the time
specified in *req. The function can return earlier if a signal has
been delivered to the process. In this case, it returns ?1, sets errno
to EINTR, and writes the remaining time into the structure pointed to
by rem unless rem is NULL. The value of *rem can then be used to call
nanosleep again and complete the specified pause. |
|