且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

pthread和信号量在osx maverick 10.9中对我不起作用

更新时间:2023-01-20 09:02:09

OSX不支持未命名的POSIX信号灯.如果检查返回码,您将看到sem_init失败,并在这些行上出现错误.您需要使用命名信号量.

Unnamed POSIX semaphores are not supported on OSX. If you check your return codes you will see sem_init fail with an error along those lines. You need to use named semaphores.

使用sem_open代替sem_init.不要使用sem_destroy,而是使用sem_close和sem_unlink.

Use sem_open instead of sem_init. Don't use sem_destroy but rather sem_close and sem_unlink.

您会很高兴.