Init semaphore to 1 or 0 */
| 552 | |
| 553 | /* Init semaphore to 1 or 0 */ |
| 554 | static void bsem_init(bsem *bsem_p, int value) { |
| 555 | if(value < 0 || value > 1) { |
| 556 | err("bsem_init(): Binary semaphore can take only values 1 or 0"); |
| 557 | exit(1); |
| 558 | } |
| 559 | pthread_mutex_init(&(bsem_p->mutex), NULL); |
| 560 | pthread_cond_init(&(bsem_p->cond), NULL); |
| 561 | bsem_p->v = value; |
| 562 | } |
| 563 | |
| 564 | /* Reset semaphore to 0 */ |
| 565 | static void bsem_reset(bsem *bsem_p) { |
no outgoing calls
no test coverage detected