forked from afilgueira/hilolay
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhilolay.h
71 lines (57 loc) · 1.54 KB
/
hilolay.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef hilolay_h__
#define hilolay_h__
/* Interface for programs, this is what the programs should use and is implemented in hilolay_internal */
// TODO: Not working in program without struct, even though it has typedef
typedef struct hilolay_t {
int tid;
} hilolay_t;
typedef struct hilolay_attr_t {
int attrs;
} hilolay_attr_t;
typedef struct hilolay_sem_t {
char *name;
} hilolay_sem_t;
/**
* Initializes the library. Implemented in the client interface.
*
* Must call hilolay.c#_init function
*/
void hilolay_init(void);
/**
* Starts an hilolay thread
*/
int hilolay_create(hilolay_t *thread, const hilolay_attr_t *attr, void *(*start_routine)(void *), void *arg);
/**
* Forces a Thread scheduled swap
*/
int hilolay_yield(void);
/**
* Joins the given `thread` to the current thread.
*/
int hilolay_join(hilolay_t *thread);
/**
* Returns the tid of the current thread.
*/
int hilolay_get_tid(void);
/**
* Initializes a named hilolay semaphore.
*/
hilolay_sem_t* hilolay_sem_open(char *name);
/**
* Closes a named hilolay semaphore.
*/
int hilolay_sem_close(hilolay_sem_t*);
/**
* Does a wait operation over a semaphore. It blocks the thread if no resources available.
*/
int hilolay_wait(hilolay_sem_t *sem);
/**
* Does a signal operation over a semaphore.
*/
int hilolay_signal(hilolay_sem_t *sem);
/**
* Returns and closes a thread
* Note: Replaces a return statement on the original thread that called hilolay_init.
*/
int hilolay_return(int value);
#endif // hilolay_h__