-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmythread.h
More file actions
62 lines (49 loc) · 1.63 KB
/
mythread.h
File metadata and controls
62 lines (49 loc) · 1.63 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
58
59
60
61
62
/******************************************************************************
*
* File Name........: mythread.h
*
* Description......:
*
* Created by vin on 11/21/06
*
* Revision History.:
*
*
*****************************************************************************/
#ifndef MYTHREAD_H
#define MYTHREAD_H
// Leave these definitions alone. They are opaque handles. The
// public definition of these should not contain the internal
// structure.
// In the library routines you should cast these parameters to their
// internals definitions. Eg,
// _MyThread internal_name = (_MyThread)parameter_name;
// and when returning these handles to the user
// MyThread parameter_name = (MyThread)internal_name;
typedef void *MyThread;
typedef void *MySemaphore;
// ****** THREAD OPERATIONS ******
// Create a new thread.
MyThread MyThreadCreate(void(*start_funct)(void *), void *args);
// Yield invoking thread
void MyThreadYield(void);
// Join with a child thread
int MyThreadJoin(MyThread thread);
// Join with all children
void MyThreadJoinAll(void);
// Terminate invoking thread
void MyThreadExit(void);
// ****** SEMARPHORE OPERATIONS ******
// Create a semaphore
MySemaphore MySemaphoreInit(int initialValue);
// Signal a semaphore
void MySemaphoreSignal(MySemaphore sem);
// Wait on a semaphore
void MySemaphoreWait(MySemaphore sem);
// ****** CALLS ONLY FOR UNIX PROCESS ******
// Create the "main" thread
void MyThreadInit(void(*start_funct)(void *), void *args);
// Start running the "main" thread
void MyThreadRun(void);
#endif /* MYTHREAD_H */
/*........................ end of mythread.h ................................*/