23,217
社区成员




有两种情况:
先wait再post不能唤醒
+----------------------------+--------------------+----------------+
|sem_init(&sem_001, 0, 0) |... |... |
+----------------------------+--------------------+----------------+
|thread 1 |thread 2 |thread other |
+----------------------------+--------------------+----------------+
|sem_wait(&sem_001) |... |no sem func |
|... |sem_post(&sem_001) |no sem func |
|can not wakeup |... |... |
+----------------------------+--------------------+----------------+
先post再wait可以唤醒
+----------------------------+--------------------+----------------+
|sem_init(&sem_001, 0, 0) |... |... |
+----------------------------+--------------------+----------------+
|thread 1 |thread 2 |thread other |
+----------------------------+--------------------+----------------+
|... |sem_post(&sem_001) |no sem func |
|sem_wait(&sem_001) |... |no sem func |
|can wakeup |... |... |
+----------------------------+--------------------+----------------+