-
Notifications
You must be signed in to change notification settings - Fork 0
/
megos_synchronization.h
53 lines (43 loc) · 955 Bytes
/
megos_synchronization.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* megos_synchronization.h
*
* Created: 1/13/2018 9:05:21 AM
* Author: Matthew
*/
#ifndef MEGOS_SYNCHRONIZATION_H_
#define MEGOS_SYNCHRONIZATION_H_
typedef signed int* semaphore;
/*
* megos_new_sem(usnigned int)
*
* Allocates a new semaphore. Returns a pointer to it.
*
* @Return: Returns pointer to new semaphore.
*/
int* megos_new_sem(unsigned int sem_val);
/*
* megos_del_sem(semaphore)
*
* Frees the semaphore if it was allocated by megos_new_sem.
*
* @Param sem: Semaphore to free.
*/
void megos_del_sem(semaphore sem);
/*
* megos_sem_V(semaphore)
*
* Increment and wake a waiting thread on semaphore.
*
* @Param sem: Semaphore to increment.
*/
void megos_sem_V(semaphore sem);
/*
* megos_sem_P(semaphore)
*
* Decrement and block if *sem is negative.
*
* @Param sem: Semaphore to decrement.
*/
void megos_sem_P(semaphore sem);
void megos_sem_P_stop_starve(semaphore sem, semaphore stop_sem);
#endif /* MEGOS_SYNCHRONIZATION_H_ */