{"id":680,"date":"2022-08-30T15:05:23","date_gmt":"2022-08-30T15:05:23","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/problem-about-condition-variable-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:05:23","modified_gmt":"2022-08-30T15:05:23","slug":"problem-about-condition-variable-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-condition-variable-collection-of-common-programming-errors\/","title":{"rendered":"problem about condition-variable-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/iMOen.png?s=32&amp;g=1\" \/><br \/>\nuser462608<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cceb28429bf4f1ff3ba5a6c3818313bd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nweidongxu<br \/>\nc++ mutex condition-variable<br \/>\nI would like to ask whether it is OK to use 1 condition variable associated with 2 mutex, for 2 kind of data update.Basically, I have thread1 and thread2. Thread1 could wait for 2 kinds of data update, so it got 2 mutex, one for each. (I know I could use one mutex for all these data, but this is not the point of this question, right?) And I certainly does not want it be waiting on data1 while data2 is already available, so i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/73c5967cf90e62b10d34b1d2d0ad3aae?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nR..<br \/>\nc linux pthreads condition-variable futex<br \/>\nI&#8217;m implementing pthread condition variables (based on Linux futexes) and I have an idea for avoiding the &#8220;stampede effect&#8221; on pthread_cond_broadcast with process-shared condition variables. For non-process-shared cond vars, futex requeue operations are traditionally (i.e. by NPTL) used to requeue waiters from the cond var&#8217;s futex to the mute<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/24b06823d7bcd51da0a3236411c4d57f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTyler McHenry<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:36:35. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>user462608 weidongxu c++ mutex condition-variable I would like to ask whether it is OK to use 1 condition variable associated with 2 mutex, for 2 kind of data update.Basically, I have thread1 and thread2. Thread1 could wait for 2 kinds of data update, so it got 2 mutex, one for each. (I know I could [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-680","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=680"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/680\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}