Re: [問題] pthread問題

看板C_and_CPP作者 (艾斯寇德)時間15年前 (2009/08/08 14:38), 編輯推噓3(300)
留言3則, 2人參與, 最新討論串3/3 (看更多)
這是其中一個版本,也就是只影響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)

08/08 15:54, , 1F
剛剛在bsd7測試,thread內sleep,ps看到所有thread都是S狀態
08/08 15:54, 1F

08/08 15:57, , 2F
所以假設是所有process被暫停,原問題...我還是想不透
08/08 15:57, 2F

08/09 08:35, , 3F
不同的實做?
08/09 08:35, 3F
文章代碼(AID): #1AVHrHVf (C_and_CPP)
文章代碼(AID): #1AVHrHVf (C_and_CPP)