首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

急 ! 延迟函数

2012-09-08 
急 !!! 求救延迟函数谁能告诉我sleepusleep select nanosleep的区别能告诉我 正规的地方给我去查询 这方面

急 !!! 求救 延迟函数
谁能告诉我sleep usleep select nanosleep 的区别

能告诉我 正规的地方给我去查询 这方面的资料  

谢谢 答案 合理 就给分

[解决办法]
sleep windows下的挂起函数 
usleep nanosleep linux下的挂起函数
都是把进程挂起一些时间 
直接百度谷歌很多的,相对来说nanosleep 更准确一些
至于select?C语言?这个是SQL的关键字吧?
[解决办法]
sleep usleep nanosleep 精度不一样,其他没什么区别
当然你愿意也可以由poll(ms)、select(us)、ppoll或pslect(ns)等来实现各种精度的sleep
[解决办法]
windows下MSDN、unix/linux下man都可以
MSDN在线http://msdn.microsoft.com/zh-cn/
[解决办法]
MSDN这个是最详细的了。。。
[解决办法]
查MSDN是Windows程序员必须掌握的技能之一。

Sleep
The Sleep function suspends the execution of the current thread for a specified interval. 

VOID Sleep(
DWORD dwMilliseconds // sleep time in milliseconds
);
 
Parameters
dwMilliseconds 
Specifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay. 
Return Values
This function does not return a value. 

Remarks
A thread can relinquish the remainder of its time slice by calling this function with a sleep time of zero milliseconds. 

You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than Sleep.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.

See Also
Processes and Threads Overview, Process and Thread Functions, MsgWaitForMultipleObjects, MsgWaitForMultipleObjectsEx, SleepEx 

 
用man指令查函数用法是Linux程序员必须掌握的技能之一。
man usleepUSLEEP(3) Linux Programmer's Manual USLEEP(3)

NAME
usleep - suspend execution for microsecond intervals

SYNOPSIS
#include <unistd.h>

int usleep(useconds_t usec);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

usleep(): _BSD_SOURCE || _XOPEN_SOURCE >= 500

DESCRIPTION
The usleep() function suspends execution of the calling process for (at least) usec microseconds. The sleep may be lengthened slightly by any
system activity or by the time spent processing the call or by the granularity of system timers.

RETURN VALUE
0 on success, -1 on error.

ERRORS
EINTR Interrupted by a signal; see signal(7).

EINVAL usec is not smaller than 1000000. (On systems where that is considered an error.)

CONFORMING TO
4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete; use nanosleep(2) instead. POSIX.1-2008 removes the specification of


usleep().

On the original BSD implementation, and in glibc before version 2.2.2, the return type of this function is void. The POSIX version returns int,
and this is also the prototype used since glibc 2.2.2.

Only the EINVAL error return is documented by SUSv2 and POSIX.1-2001.

NOTES
The type useconds_t is an unsigned integer type capable of holding integers in the range [0,1000000]. Programs will be more portable if they
never mention this type explicitly. Use

#include <unistd.h>
...
unsigned int usecs;
...
usleep(usecs);

The interaction of this function with the SIGALRM signal, and with other timer functions such as alarm(2), sleep(3), nanosleep(2), setitimer(2),
timer_create(2), timer_delete(2), timer_getoverrun(2), timer_gettime(2), timer_settime(2), ualarm(3) is unspecified.

SEE ALSO
alarm(2), getitimer(2), nanosleep(2), select(2), setitimer(2), sleep(3), ualarm(3), time(7)

COLOPHON
This page is part of release 3.23 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be
found at http://www.kernel.org/doc/man-pages/.

2007-07-26 USLEEP(3)

英语也是一门计算机语言的说。


[解决办法]
sleep秒
usleep微妙
nanosleep纳秒

热点排行