{"id":83,"date":"2011-06-27T03:31:11","date_gmt":"2011-06-27T07:31:11","guid":{"rendered":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/?p=83"},"modified":"2011-06-27T03:31:11","modified_gmt":"2011-06-27T07:31:11","slug":"sem_init-function-not-implemented","status":"publish","type":"post","link":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/2011\/06\/27\/sem_init-function-not-implemented\/","title":{"rendered":"sem_init: &#8216;Function Not Implemented&#8217;"},"content":{"rendered":"<p>I&#8217;ve been doing some thread related code lately and just came across a problem.  I&#8217;m using a semaphore for a producer\/consumer solution around a shared resource, the build thread to be exact.  So multiple producers are wanting to flag that a build needs to be done, but there&#8217;s only one consumer (the actual build thread).<\/p>\n<p>Finished up all the code and then hit play only to find that my build thread ran continuously and never waited.  In fact it would run without a call to build!  After adding in some checks on return statements I find out that sem_init always fails when trying to create my semaphore: &#8220;Function Not Implemented.&#8221;<\/p>\n<p>Turns out Apple decided not to implement unnamed semaphores \ud83d\ude41 Instead you&#8217;re supposed to use named semaphores.  Well I&#8217;m not a fan!  Named semaphores are available to other processes too.  That means that two apps can both open the same named semaphore and interact (note: I haven&#8217;t actually tested if apps can &#8216;actually&#8217; cross boundaries on iOS, but they can on other systems and portability is important for the engine).  And since this is in generic engine code, I can&#8217;t just pick a really unique name cause it would clash between two or more games based on the same engine.<\/p>\n<p>As the CEO of Yahoo recently stated, &#8220;<a title=\"Downer\" href=\"http:\/\/techcrunch.com\/2011\/06\/24\/yahoo-shareholder-bartz\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/techcrunch.com']);\" target=\"_blank\">that was certainly a downer<\/a>.&#8221;  Guess I&#8217;m going to have to come up with my own solution now.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been doing some thread related code lately and just came across a problem. I&#8217;m using a semaphore for a producer\/consumer solution around a shared resource, the build thread to be exact. So multiple producers are wanting to flag that a build needs to be done, but there&#8217;s only one consumer (the actual build thread). [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":2,"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":85,"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/posts\/83\/revisions\/85"}],"wp:attachment":[{"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/GetOffMyLawnEntertainment.com\/blog\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}