-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcond.h
More file actions
57 lines (50 loc) · 1.45 KB
/
cond.h
File metadata and controls
57 lines (50 loc) · 1.45 KB
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
54
55
56
57
/**
* @file cond.h
* @author Skand Hurkat
* @copyright All rights reserved 2015
*
* This file defines conditional variables for concurrent execution
*
* @warning This file is offered AS IS and WITHOUT ANY WARRANTY, without
* even the implied warranties of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*/
#ifndef __COND_H_INCLUDED__
#define __COND_H_INCLUDED__
#include "3140_concur.h"
#include "shared_structs.h"
/**
* Initialises the conditional variable structure
*
* @param l ignored
* @param c pointer to conditional variable to be initialised
*/
void c_init(lock_t* l, cond_t* c);
/**
* wait until condition is true
*
* @param l pointer to lock/mutex for conditional variable
* @param c pointer to conditional variable
*/
void c_wait(lock_t* l, cond_t* c);
/**
* Check if processes are waiting on conditional variable
*
* @param l Pointer to lock/mutex. Not used, but mutex must be acquired
* before calling to ensure atomicity
* @param c pointer to conditional variable
*
* @return 0 if no processes waiting
* @return 1 if processes waiting
*/
int c_waiting(lock_t* l, cond_t* c);
/**
* Signal that condition is met
*
* @warning Will misbehave if no processes are waiting and is signalled
*
* @param l pointer to lock (is released after signalling)
* @param c pointer to conditional variable
*/
void c_signal(lock_t* l, cond_t* c);
#endif /* __LOCK_H_INCLUDED */