Forum > C++ > sem_init bug in CCTextureCache.cpp

sem_init bug in CCTextureCache.cpp

By keith Posted 2012-04-24 04:00 Comments 4
keith
  • Posts: 4

hi - the sem_init() call is not supported on ios. it will set errno and fail to create a semaphore, meaning the sem_wait() call in the main run loop will return immediately. only named semaphores (using sem_open) are supported. i’m not sure how this affects other platforms.

http://www.lastrayofhope.com/2011/03/15/ios-semaphore-problems/
http://getoffmylawnentertainment.com/blog/2011/06/27/sem\_init-function-not-implemented/

zhangxm
  • Posts: 2082
  • Location: Xiamen, China

#1 RE: 2012-04-25 03:38

Does official Apple documents confirm it?

keith
  • Posts: 4

#2 RE: 2012-04-27 16:23

If you call sem_init the return val is –1, and if you check errno after the call it is set to 78 (Function not implemented). I haven’t seen any other documentation about it.

Weeds
  • Posts: 75

#3 RE: 2012-04-28 09:09

I can confirm this as well, using the async texture loader will put the loading thread into a busy loop as the semaphore call fails instantly.
On an iPad2 I had about 120-150 CPU usage with the loading thread active (and idle) and about 20-30 without.
It wasn’t really affecting performance as this happend on the 2nd core, but may drain the battery a lot.

zhangxm
  • Posts: 2082
  • Location: Xiamen, China

#4 RE: 2012-05-03 05:49

Thank you.

#1214 is created for it.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps