task.h
3.38 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Copyright (C) 1998 by the Board of Trustees
* of Leland Stanford Junior University.
* Copyright (C) 1998 Digital Equipment Corporation
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
#ifndef _TASK_H_
#define _TASK_H_
/*
* Definition of the event structure and bit field mnemonics
*/
#include <values.h>
#include "event.h"
#include "export.h"
/* The order of the first few fields is important.
* The time wheel defines a struct that contains only next, prev, time
* and priority.
*/
typedef struct task {
struct task *next;
struct task *prev;
aint_time_t time;
int priority; /* larger number == higher priority */
int pid;
int (*ufunc) (struct task *); /* user-defined function to call */
struct task *tstack; /* stack of tasks to execute next */
struct event *pevent; /* pointer to an event structure */
long ival1; /* user-defined integer value */
long ival2; /* user-defined integer value */
long ival3; /* user-defined integer value */
long ival4; /* user-defined integer value */
long ival5; /* user-defined integer value */
long ival6; /* user-defined integer value */
double dval1; /* user-defined double value */
double dval2; /* user-defined double value */
aint_time_t tval1; /* user-defined time value */
aint_time_t tval2; /* user-defined time value */
aint_time_t tval3; /* user-defined time value */
void *uptr; /* user-defined pointer */
void *uptr2; /* user-defined pointer */
void *uptr3; /* user-defined pointer */
void *uptr4; /* user-defined pointer */
long virtual_address; /* user-defined to contain value of
ptask->pevent->vaddr */
long event_type; /* user-defined to contain value of
ptask->pevent->type */
int (*ufunc2) (struct task *); /* user-defined function pointer */
struct task *unext; /* user-defined forward link */
struct task *uprev; /* user-defined backward link */
/*
* There are supposed to be more things in here, that the user may define.
* Will deal with them later
*/
} task_t, *task_ptr;
typedef int (*PFTASK) (struct task * ptask);
/* the default priority */
#define DEF_PRIORITY 0
#define PRIORITY_HIGH (~(1 << 31))
#define PRIORITY_LOW (1 << 31)
#define T_ADVANCE 0
#define T_FREE 1
#define T_NO_ADVANCE T_FREE /* For backwards compatibility? */
#define T_YIELD 2
#define T_CONTINUE 3
#define T_MAX 5 /* Must be last */
#ifdef __cplusplus
extern "C" {
#endif
/* Function prototypes */
int wait_for_children (thread_ptr pthread);
int wait_for_child (thread_ptr pthread);
int task_yield (task_ptr ptask);
int task_exit (task_ptr ptask);
int task_done (task_ptr ptask);
int task_fork (task_ptr ptask);
int task_m_fork (task_ptr ptask);
int task_block (task_ptr ptask);
int task_timed_block (task_ptr ptask);
int task_unblock (task_ptr ptask);
int task_unblock_list (task_ptr ptask);
int task_terminate (task_ptr ptask);
task_ptr pri_sched_task (task_ptr ptask, PFTASK ufunc, aint_time_t tval,
int priority);
task_ptr stack_task (task_ptr ptask, PFTASK ufunc);
task_ptr sched_task (task_ptr ptask, PFTASK ufunc, aint_time_t tval);
task_ptr schedule_task (task_ptr pnew);
task_ptr new_task (task_ptr ptask);
task_ptr newtask ();
void free_task (task_ptr ptask);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _TASK_H_ */