#include "core.h"
#include <semaphore.h>
Go to the source code of this file.
◆ semaphore_init()
| int semaphore_init |
( |
struct Semaphore * | s, |
|
|
const char * | name, |
|
|
int | value ) |
Initialize a cross-platform semaphore (Linux/Darwin)
c
int main(int argc, char *argv[]) {
perror("semaphore_init failed");
exit(1);
}
if (semaphore_wait(&s)) {
perror("semaphore_wait failed");
exit(1);
}
if (semaphore_post(&s)) {
perror("semaphore_post failed");
exit(1);
}
semaphore_destroy(&s);
}
int semaphore_init(struct Semaphore *s, const char *name, int value)
Definition semaphore.c:33
- Parameters
-
| s | a pointer to Semaphore |
| name | of the semaphore |
| value | initial value of the semaphore |
- Returns
- -1 on error
-
0 on success