亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? readme.cv

?? pthread source code,you can compile directly
?? CV
?? 第 1 頁 / 共 5 頁
字號:
too   * This sync.level supports _timedwait and cancellation   */  else    {      result = pthread_mutex_unlock(&(cv->mtxUnblockLock));    }  return(result);}                               /* ptw32_cond_unblock */intpthread_cond_wait (pthread_cond_t * cond,                   pthread_mutex_t * mutex){  /* The NULL abstime arg means INFINITE waiting. */  return(ptw32_cond_timedwait(cond, mutex, NULL));}                               /* pthread_cond_wait */intpthread_cond_timedwait (pthread_cond_t * cond,                        pthread_mutex_t * mutex,                        const struct timespec *abstime){  if (abstime == NULL)    {(abstime      return EINVAL;    }  return(ptw32_cond_timedwait(cond, mutex, abstime));}                               /* pthread_cond_timedwait */intpthread_cond_signal (pthread_cond_t * cond){  /* The '0'(FALSE) unblockAll arg means unblock ONE waiter. */  return(ptw32_cond_unblock(cond, 0));}                               /* pthread_cond_signal */intpthread_cond_broadcast (pthread_cond_t * cond){  /* The '1'(TRUE) unblockAll arg means unblock ALL waiters. */  return(ptw32_cond_unblock(cond, 1));}                               /* pthread_cond_broadcast */TEREKHOV@de.ibm.com on 17.01.2001 01:00:57Please respond to TEREKHOV@de.ibm.comTo:   pthreads-win32@sourceware.cygnus.comcc:   schmidt@uci.eduSubject:  win32 conditions: sem+counter+event = broadcast_deadlock +      spur.wakeup/unfairness/incorrectness ??Hi,Problem 1: broadcast_deadlockIt seems that current implementation does not provide "atomic"broadcasts. That may lead to "nested" broadcasts... and it seemsthat nested case is not handled correctly -> producing a broadcastDEADLOCK as a result.Scenario:N (>1) waiting threads W1..N are blocked (in _wait) on condition'ssemaphore.Thread B1 calls pthread_cond_broadcast, which results in "releasing" NW threads via incrementing semaphore counter by N (stored incv->waiters) BUT cv->waiters counter does not change!! The callerthread B1 remains blocked on cv->waitersDone event (auto-reset!!) BUTcondition is not protected from starting another broadcast (when calledon another thread) while still waiting for the "old" broadcast tocomplete on thread B1.M (>=0, <N) W threads are fast enough to go thru their _wait call anddecrement cv->waiters counter.L (N-M) "late" waiter W threads are a) still blocked/not returned fromtheir semaphore wait call or b) were preempted after sem_wait but beforelock( &cv->waitersLock ) or c) are blocked on cv->waitersLock.cv->waiters is still > 0 (= L).Another thread B2 (or some W thread from M group) callspthread_cond_broadcast and gains access to counter... neither a) nor b)prevent thread B2 in pthread_cond_broadcast from gaining access tocounter and starting another broadcast ( for c) - it depends oncv->waitersLock scheduling rules: FIFO=OK, PRTY=PROBLEM,... )That call to pthread_cond_broadcast (on thread B2) will result inincrementing semaphore by cv->waiters (=L) which is INCORRECT (allW1..N were in fact already released by thread B1) and waiting on_auto-reset_ event cv->waitersDone which is DEADLY WRONG (produces adeadlock)...All late W1..L threads now have a chance to complete their _wait call.Last W_L thread sets an auto-reselt event cv->waitersDone which willrelease either B1 or B2 leaving one of B threads in a deadlock.Problem 2: spur.wakeup/unfairness/incorrectnessIt seems that:a) because of the same problem with counter which does not reflect theactual number of NOT RELEASED waiters, the signal call may incrementa semaphore counter w/o having a waiter blocked on it. That will resultin (best case) spurious wake ups - performance degradation due tounnecessary context switches and predicate re-checks and (in worth case)unfairness/incorrectness problem - see b)b) neither signal nor broadcast prevent other threads - "new waiters"(and in the case of signal, the caller thread as well) from going into_wait and overtaking "old" waiters (already released but still not returnedfrom sem_wait on condition's semaphore). Win semaphore just [API DOC]:"Maintains a count between zero and some maximum value, limiting the numberof threads that are simultaneously accessing a shared resource." CallingReleaseSemaphore does not imply (at least not documented) that on returnfrom ReleaseSemaphore all waiters will in fact become released (returnedfrom their Wait... call) and/or that new waiters calling Wait... afterwardswill become less importance. It is NOT documented to be an atomic releaseofwaiters... And even if it would be there is still a problem with a threadbeing preempted after Wait on semaphore and before Wait on cv->waitersLockand scheduling rules for cv->waitersLock itself(??WaitForMultipleObjects??)That may result in unfairness/incorrectness problem as describedfor SetEvent impl. in "Strategies for Implementing POSIX ConditionVariableson Win32": http://www.cs.wustl.edu/~schmidt/win32-cv-1.htmlUnfairness -- The semantics of the POSIX pthread_cond_broadcast function isto wake up all threads currently blocked in wait calls on the conditionvariable. The awakened threads then compete for the external_mutex. Toensurefairness, all of these threads should be released from theirpthread_cond_wait calls and allowed to recheck their condition expressionsbefore other threads can successfully complete a wait on the conditionvariable.Unfortunately, the SetEvent implementation above does not guarantee thatallthreads sleeping on the condition variable when cond_broadcast is calledwillacquire the external_mutex and check their condition expressions. Althoughthe Pthreads specification does not mandate this degree of fairness, thelack of fairness can cause starvation.To illustrate the unfairness problem, imagine there are 2 threads, C1 andC2,that are blocked in pthread_cond_wait on condition variable not_empty_ thatis guarding a thread-safe message queue. Another thread, P1 then places twomessages onto the queue and calls pthread_cond_broadcast. If C1 returnsfrompthread_cond_wait, dequeues and processes the message, and immediatelywaitsagain then it and only it may end up acquiring both messages. Thus, C2 willnever get a chance to dequeue a message and run.The following illustrates the sequence of events:1.   Thread C1 attempts to dequeue and waits on CV non_empty_2.   Thread C2 attempts to dequeue and waits on CV non_empty_3.   Thread P1 enqueues 2 messages and broadcasts to CV not_empty_4.   Thread P1 exits5.   Thread C1 wakes up from CV not_empty_, dequeues a message and runs6.   Thread C1 waits again on CV not_empty_, immediately dequeues the 2nd        message and runs7.   Thread C1 exits8.   Thread C2 is the only thread left and blocks forever since        not_empty_ will never be signaledDepending on the algorithm being implemented, this lack of fairness mayyieldconcurrent programs that have subtle bugs. Of course, applicationdevelopersshould not rely on the fairness semantics of pthread_cond_broadcast.However,there are many cases where fair implementations of condition variables cansimplify application code.Incorrectness -- A variation on the unfairness problem described aboveoccurswhen a third consumer thread, C3, is allowed to slip through even though itwas not waiting on condition variable not_empty_ when a broadcast occurred.To illustrate this, we will use the same scenario as above: 2 threads, C1andC2, are blocked dequeuing messages from the message queue. Another thread,P1then places two messages onto the queue and calls pthread_cond_broadcast.C1returns from pthread_cond_wait, dequeues and processes the message. At thistime, C3 acquires the external_mutex, calls pthread_cond_wait and waits onthe events in WaitForMultipleObjects. Since C2 has not had a chance to runyet, the BROADCAST event is still signaled. C3 then returns fromWaitForMultipleObjects, and dequeues and processes the message in thequeue.Thus, C2 will never get a chance to dequeue a message and run.The following illustrates the sequence of events:1.   Thread C1 attempts to dequeue and waits on CV non_empty_2.   Thread C2 attempts to dequeue and waits on CV non_empty_3.   Thread P1 enqueues 2 messages and broadcasts to CV not_empty_4.   Thread P1 exits5.   Thread C1 wakes up from CV not_empty_, dequeues a message and runs6.   Thread C1 exits7.   Thread C3 waits on CV not_empty_, immediately dequeues the 2nd        message and runs8.   Thread C3 exits9.   Thread C2 is the only thread left and blocks forever since        not_empty_ will never be signaledIn the above case, a thread that was not waiting on the condition variablewhen a broadcast occurred was allowed to proceed. This leads to incorrectsemantics for a condition variable.COMMENTS???regards,alexander.-----------------------------------------------------------------------------Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_*     implementation questionsDate: Wed, 21 Feb 2001 11:54:47 +0100From: TEREKHOV@de.ibm.comTo: lthomas@arbitrade.comCC: rpj@ise.canberra.edu.au, Thomas Pfaff <tpfaff@gmx.net>,     Nanbor Wang <nanbor@cs.wustl.edu>Hi Louis,generation number 8..had some time to revisit timeouts/spurious wakeup problem..found some bugs (in 7.b/c/d) and something to improve(7a - using IPC semaphores but it should speedup Win32version as well).regards,alexander.---------- Algorithm 8a / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL ------given:semBlockLock - bin.semaphoresemBlockQueue - semaphoremtxExternal - mutex or CSmtxUnblockLock - mutex or CSnWaitersGone - intnWaitersBlocked - intnWaitersToUnblock - intwait( timeout ) {  [auto: register int result          ]     // error checking omitted  [auto: register int nSignalsWasLeft ]  [auto: register int nWaitersWasGone ]  sem_wait( semBlockLock );  nWaitersBlocked++;  sem_post( semBlockLock );  unlock( mtxExternal );  bTimedOut = sem_wait( semBlockQueue,timeout );  lock( mtxUnblockLock );  if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) {    if ( bTimeout ) {                       // timeout (or canceled)      if ( 0 != nWaitersBlocked ) {        nWaitersBlocked--;      }      else {        nWaitersGone++;                     // count spurious wakeups      }    }    if ( 0 == --nWaitersToUnblock ) {      if ( 0 != nWaitersBlocked ) {        sem_post( semBlockLock );           // open the gate        nSignalsWasLeft = 0;                // do not open the gate belowagain      }      else if ( 0 != (nWaitersWasGone = nWaitersGone) ) {        nWaitersGone = 0;      }    }  }  else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurioussemaphore :-)    sem_wait( semBlockLock );    nWaitersBlocked -= nWaitersGone;        // something is going on here -test of timeouts? :-)    sem_post( semBlockLock );    nWaitersGone = 0;  }  unlock( mtxUnblockLock );  if ( 1 == nSignalsWasLeft ) {    if ( 0 != nWaitersWasGone ) {      // sem_adjust( -nWaitersWasGone );      while ( nWaitersWasGone-- ) {        sem_wait( semBlockLock );          // better now than spuriouslater      }    }    sem_post( semBlockLock );              // open the gate  }  lock( mtxExternal );  return ( bTimedOut ) ? ETIMEOUT : 0;}signal(bAll) {  [auto: register int result         ]  [auto: register int nSignalsToIssue]  lock( mtxUnblockLock );  if ( 0 != nWaitersToUnblock ) { // the gate is closed!!!    if ( 0 == nWaitersBlocked ) { // NO-OP      return unlock( mtxUnblockLock );    }    if (bAll) {      nWaitersToUnblock += nSignalsToIssue=nWaitersBlocked;      nWaitersBlocked = 0;    }    else {      nSignalsToIssue = 1;      nWaitersToUnblock++;      nWaitersBlocked--;    }  }  else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION!    sem_wait( semBlockLock ); // close the gate    if ( 0 != nWaitersGone ) {      nWaitersBlocked -= nWaitersGone;      nWaitersGone = 0;    }    if (bAll) {      nSignalsToIssue = nWaitersToUnblock = nWaitersBlocked;      nWaitersBlocked = 0;    }    else {      nSignalsToIssue = nWaitersToUnblock = 1;      nWaitersBlocked--;    }  }  else { // NO-OP    return unlock( mtxUnblockLock );  }  unlock( mtxUnblockLock );  sem_post( semBlockQueue,nSignalsToIssue );  return result;}---------- Algorithm 8b / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ONEBYONE------given:semBlockLock - bin.semaphoresemBlockQueue - bin.semaphoremtxExternal - mutex or CSmtxUnblockLock - mutex or CSnWaitersGone - intnWaitersBlocked - intnWaitersToUnblock - intwait( timeout ) {  [auto: register int result          ]     // error checking omitted  [auto: register int nWaitersWasGone ]  [auto: register int nSignalsWasLeft ]  sem_wait( semBlockLock );  nWaitersBlocked++;  sem_post( semBlockLock );  unlock( mtxExternal );  bTimedOut = sem_wait( semBlockQueue,timeout );  lock( mtxUnblockLock );  if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) {    if ( bTimeout ) {                       // timeout (or canceled)      if ( 0 != nWaitersBlocked ) {        nWaitersBlocked--;        nSignalsWasLeft = 0;                // do not unblock next waiterbelow (already unblocked)      }      else {        nWaitersGone = 1;                   // spurious wakeup pending!!      }    }    if ( 0 == --nWaitersToUnblock &&      if ( 0 != nWaitersBlocked ) {        sem_post( semBlockLock );           // open the gate        nSignalsWasLeft = 0;                // do not open the gate belowagain      }      else if ( 0 != (nWaitersWasGone = nWaitersGone) ) {        nWaitersGone = 0;      }    }  }  else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurioussemaphore :-)    sem_wait( semBlockLock );    nWaitersBlocked -= nWaitersGone;        // something is going on here -test of timeouts? :-)    sem_post( semBlockLock );    nWaitersGone = 0;  }  unlock( mtxUnblockLock );  if ( 1 == nSignalsWasLeft ) {    if ( 0 != nWaitersWasGone ) {      // sem_adjust( -1 );      sem_wait( semBlockQueue );           // better now than spuriouslater    }    sem_post( semBlockLock );              // open the gate  }  else if ( 0 != nSignalsWasLeft ) {    sem_post( semBlockQueue );             // unblock next waiter  }  lock( mtxExternal );  return ( bTimedOut ) ? ETIMEOUT : 0;}signal(bAll) {  [auto: register int result ]  lock( mtxUnblockLock );  if ( 0 != nWaitersToUnblock ) { // the gate is closed!!!    if ( 0 == nWaitersBlocked ) { // NO-OP      return unlock( mtxUnblockLock );    }    if (bAll) {      nWaitersToUnblock += nWaitersBlocked;      nWaitersBlocked = 0;    }    else {      nWaitersToUnblock++;      nWaitersBlocked--;    }    unlock( mtxUnblockLock );  }  else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION!    sem_wait( semBlockLock ); // close the gate    if ( 0 != nWaitersGone ) {      nWaitersBlocked -= nWaitersGone;      nWaitersGone = 0;    }    if (bAll) {      nWaitersToUnblock = nWaitersBlocked;      nWaitersBlocked = 0;    }    else {      nWaitersToUnblock = 1;      nWaitersBlocked--;    }    unlock( mtxUnblockLock );    sem_post( semBlockQueue );  }  else { // NO-OP    unlock( mtxUnblockLock );  }  return result;}---------- Algorithm 8c / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ONEBYONE---------given:hevBlockLock - auto-reset eventhevBlockQueue - auto-reset event

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩视频不卡| 国产精品久久福利| 欧美日韩一区成人| 色视频欧美一区二区三区| 91视频在线观看免费| aa级大片欧美| 一本色道久久综合狠狠躁的推荐| 99久久精品国产一区| 99在线热播精品免费| 91蝌蚪porny九色| 91免费看视频| 欧美怡红院视频| 欧美日韩一级黄| 欧美一区二区女人| 欧美电视剧在线看免费| 久久久蜜臀国产一区二区| 久久精品视频免费| 国产精品家庭影院| 一区二区三区在线视频免费观看| 亚洲一区二区三区在线| 五月激情六月综合| 毛片av一区二区三区| 国产精品自拍网站| 91视频免费播放| 欧美色手机在线观看| 欧美一区午夜视频在线观看| 精品国产自在久精品国产| 久久久久久久久蜜桃| 中文字幕在线观看一区| 亚洲一区二区视频| 精品在线播放免费| 成人av电影在线播放| 在线视频一区二区三| 91精品免费在线观看| 久久久精品蜜桃| 最新国产の精品合集bt伙计| 亚洲va欧美va天堂v国产综合| 久久激情五月激情| av影院午夜一区| 91精品国模一区二区三区| 久久久久久免费毛片精品| 亚洲欧美福利一区二区| 日本欧美一区二区| 成人性生交大合| 欧美美女一区二区三区| 久久蜜桃av一区二区天堂| 亚洲综合免费观看高清在线观看| 免费黄网站欧美| 91色综合久久久久婷婷| 欧美一级一区二区| 最新日韩av在线| 免费精品99久久国产综合精品| 成人av小说网| 欧美一级欧美一级在线播放| 国产精品人成在线观看免费 | 国产成人综合在线| 欧美三级电影在线看| 国产情人综合久久777777| 亚洲成人综合网站| 成人av电影免费观看| 日韩一区二区三区在线| 综合自拍亚洲综合图不卡区| 精品影视av免费| 欧美影院一区二区三区| 国产女人水真多18毛片18精品视频| 亚洲成国产人片在线观看| 成人综合在线网站| 日韩一级片在线观看| 亚洲女性喷水在线观看一区| 国产一区日韩二区欧美三区| 欧美视频在线观看一区二区| 国产精品免费丝袜| 国产一区二区在线视频| 欧美美女一区二区| 夜夜嗨av一区二区三区中文字幕| 国产成人av资源| 日韩一卡二卡三卡国产欧美| 亚洲图片欧美色图| 99国产精品久久久久| 国产欧美精品在线观看| 韩国欧美国产一区| 91精品婷婷国产综合久久性色| 一区二区三区在线视频免费 | 在线成人av网站| 亚洲人精品午夜| 国产精品一区二区久久精品爱涩| 7878成人国产在线观看| 一区二区三区国产精华| 91无套直看片红桃| 国产精品二三区| 成人福利在线看| 国产偷国产偷精品高清尤物| 久久99精品国产麻豆不卡| 91精品国产色综合久久不卡蜜臀| 亚洲一区二区高清| 欧美在线制服丝袜| 一区二区三区**美女毛片| 91网址在线看| 亚洲免费大片在线观看| 91在线视频免费91| 国产精品第13页| www.成人在线| 亚洲天堂精品在线观看| 成人久久视频在线观看| 国产精品国产三级国产aⅴ原创 | 久久精品噜噜噜成人88aⅴ| 4438成人网| 蜜臀av国产精品久久久久| 日韩一本二本av| 精品一区二区国语对白| 26uuu色噜噜精品一区| 国精产品一区一区三区mba视频| 日韩免费性生活视频播放| 精品在线你懂的| 久久精品一区二区三区不卡牛牛| 国产剧情一区二区| 欧美韩日一区二区三区四区| www.亚洲在线| 亚洲欧美国产三级| 欧美日韩国产中文| 日本免费新一区视频| 精品日韩在线一区| 国产成人精品免费网站| 中文字幕在线视频一区| 91精品福利视频| 亚洲成人黄色影院| 日韩欧美视频在线| 国产九色精品成人porny| 中文字幕第一区| 色婷婷久久一区二区三区麻豆| 午夜精品一区二区三区免费视频| 91麻豆精品国产自产在线| 老司机精品视频在线| 亚洲国产精品99久久久久久久久| 99re亚洲国产精品| 性欧美大战久久久久久久久| 欧美va天堂va视频va在线| 粉嫩13p一区二区三区| 亚洲欧美另类在线| 91精品国产综合久久福利软件 | 26uuu精品一区二区| 成人v精品蜜桃久久一区| 亚洲伊人伊色伊影伊综合网| 欧美一级视频精品观看| 丁香六月久久综合狠狠色| 一区二区三区中文在线| 欧美成人激情免费网| www.欧美.com| 蜜臀久久99精品久久久画质超高清 | 91精品在线免费观看| 国产盗摄女厕一区二区三区| 一区二区三区在线视频播放| 欧美sm美女调教| 91麻豆精品在线观看| 蜜桃在线一区二区三区| 亚洲欧美日韩电影| 亚洲精品在线免费观看视频| 日本韩国一区二区三区| 老司机免费视频一区二区三区| 亚洲色图清纯唯美| 日韩久久久久久| 一本一道综合狠狠老| 国产一区啦啦啦在线观看| 亚洲午夜精品久久久久久久久| 精品国产91亚洲一区二区三区婷婷| 91免费国产视频网站| 久久 天天综合| 亚洲国产中文字幕| 亚洲国产精品成人综合| 日韩精品专区在线影院重磅| 色女孩综合影院| 国产黄色精品视频| 日本欧美久久久久免费播放网| 亚洲三级在线免费观看| 久久欧美中文字幕| 欧美一级二级三级蜜桃| 欧美性猛片aaaaaaa做受| 丁香婷婷综合网| 毛片一区二区三区| 性久久久久久久久| 亚洲欧美日韩精品久久久久| 国产欧美日韩激情| 久久这里都是精品| 欧美一区二区三区在线观看| 欧美日韩国产美女| 色综合网站在线| 久久精品网站免费观看| 三级久久三级久久久| 91在线视频18| 亚洲欧洲无码一区二区三区| 激情久久久久久久久久久久久久久久| 成人综合日日夜夜| 精品国产一区二区三区不卡| 亚洲国产一二三| 日韩欧美中文一区| 亚洲一区二区三区四区在线观看| 亚洲国产另类精品专区| 精品国产精品网麻豆系列| 69堂亚洲精品首页| 欧美日韩免费在线视频|