Program using Semaphores runs fine on Linux…unexpected results on Mac osX

前端 未结 2 593
清歌不尽
清歌不尽 2020-12-06 06:57

I wrote a simple program solving the Readers-Writers problem using semaphores. It runs perfectly on Linux os, but when I run it on my Mac osX I get unexpected results and I

2条回答
  •  广开言路
    2020-12-06 07:27

    Check the error return on the sem_init calls; I bet you'll find the OS X version returning a "Function not implemented" error.

    This is because unnamed POSIX semaphores are not implemented on OS X. You need to use named semaphores, or pthread mutex/condition variables.

提交回复
热议问题