看板 C_and_CPP 關於我們 聯絡資訊
這是其中一個版本,也就是只影響thread的 ( POSIX Programmer's Manual (P) Updated: 2003 ) The sleep() function shall cause the calling thread to be suspended from execution until either the number of realtime seconds specified by the argument seconds has elapsed or a signal is delivered to the calling thread and its action is to invoke a signal-catching function or to terminate the process. The suspension time may be longer than requested due to the scheduling of other activity by the system. 在這個說明底下有的Rationale There are two general approaches to the implementation of the sleep() function. One is to use the alarm() function to schedule a SIGALRM signal and then suspend the process waiting for that signal. The other is to implement an independent facility. This volume of IEEE Std 1003.1-2001 permits either approach. ... ========================================================================= 這是另一個版本 ,影響process的sleep ( Linux Programmer's Manual (3 ) Updated: 1993-04-07 ) sleep() makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored. ----------------- 我不曉得pthread_delay_np 不過應該可以用pthread_cond_timedwait達成 timespec.tv_sec = time(NULL) + 秒 timespec.tv_nsec = 0; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.171.83.59 ※ 編輯: sunneo 來自: 118.171.83.59 (08/08 15:06)
justinC:剛剛在bsd7測試,thread內sleep,ps看到所有thread都是S狀態 08/08 15:54
justinC:所以假設是所有process被暫停,原問題...我還是想不透 08/08 15:57
buganini:不同的實做? 08/09 08:35