1 |
#ifndef __SEMAPHORE_H |
2 |
#define __SEMAPHORE_H |
3 |
|
4 |
#define SEM_VALUE_MAX 64 |
5 |
|
6 |
#if defined(c_plusplus) || defined(__cplusplus) |
7 |
extern "C" { |
8 |
#endif /* c_plusplus || __cplusplus */ |
9 |
|
10 |
typedef struct psem { |
11 |
pthread_mutex_t sem_lock; |
12 |
int sem_value; |
13 |
int sem_waiting; |
14 |
} sem_t; |
15 |
|
16 |
int sem_init(sem_t* sem, int pshared, unsigned int value); |
17 |
int sem_destroy(sem_t* sem); |
18 |
sem_t sem_open(const char* name, int oflag, ...); |
19 |
int sem_close(sem_t* sem); |
20 |
int sem_unlink(const char* name); |
21 |
int sem_wait(sem_t* sem); |
22 |
int sem_trywait(sem_t* sem); |
23 |
int sem_post(sem_t* sem); |
24 |
int sem_getvalue(sem_t* sem, int* sval); |
25 |
|
26 |
#if defined(c_plusplus) || defined(__cplusplus) |
27 |
}; |
28 |
#endif /* c_plusplus || __cplusplus */ |
29 |
|
30 |
#endif /* __SEMAPHORE_H */ |