-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.h
78 lines (57 loc) · 1.16 KB
/
task.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
72
73
74
75
76
77
/* Copyright (c) 2005 Russ Cox, MIT; see COPYRIGHT */
#ifndef _TASK_H_
#define _TASK_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
* configuration
*/
typedef const struct Taskconf Taskconf;
struct Taskconf {
int32 (*usec)(void);
int32 usec_uncertainty;
void (*pauseusecs)(int32);
/* Memfill: fill memory with a pattern */
void (*memfill)(uint32 *p, int size);
};
extern Taskconf *taskconf;
/*
* basic procs and threads
*/
typedef struct Task Task;
typedef struct Tasklist Tasklist;
int anyready(void);
int taskcreate(void (*f)(void *arg), void *arg, void *stk, uint stacksize);
void taskexit(int);
int taskyield(void);
void taskswitch(void);
void needstack(int);
void taskname(char*, ...);
void taskstate(char*, ...);
void taskdelay(int32);
unsigned int taskid(void);
struct Tasklist /* used internally */
{
Task *head;
Task *tail;
};
/*
* sleep and wakeup (condition variables)
*/
typedef struct Rendez Rendez;
struct Rendez
{
Tasklist waiting;
};
void tasksleep(Rendez*);
int taskwakeup(Rendez*);
int taskwakeupall(Rendez*);
/*
* platform specific context switching
*/
extern void taskcm_handlependsv(void);
#ifdef __cplusplus
}
#endif
#endif