-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsl.h
32 lines (22 loc) · 912 Bytes
/
tsl.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
#ifndef _TSL_H_
#define _TSL_H_
// do not change this header file (tsl.h)
// it is the interface of the tsl library to the applications
#include <ucontext.h>
#define TSL_MAXTHREADS 256 // maximum number of threads (including the main thread) that an application can have.
#define TSL_STACKSIZE 32768 // bytes, i.e., 32 KB. This is the stack size for a new thread.
#define ALG_FCFS 1
#define ALG_RANDOM 2
#define ALG_MYALGORITHM 3
#define TID_MAIN 1 // tid of the main tread. this id is reserved for main thread.
#define TSL_ANY 0 // yield to a thread selected with a scheduling alg.
#define TSL_ERROR -1 // there is an error in the function execution.
#define TSL_SUCCESS 0 // function execution success
int tsl_init(int salg);
int tsl_create_thread(void (*tsf)(void*), void* targ);
int tsl_yield(int tid);
int tsl_exit();
int tsl_join(int tid);
int tsl_cancel(int tid);
int tsl_gettid();
#endif