1 | /*
|
---|
2 | =============================================================================
|
---|
3 | mtdefs.h -- mutlitasker definitions
|
---|
4 | Version 22 -- 1988-04-14 -- D.N. Lynx Crowe
|
---|
5 | (c) Copyright 1988 -- D.N. Lynx Crowe
|
---|
6 | WARNING: all of these data structures are highly ORDER DEPENDENT.
|
---|
7 | =============================================================================
|
---|
8 | */
|
---|
9 |
|
---|
10 | /* #define DEBUGGER define to enable debugging in all MT code */
|
---|
11 |
|
---|
12 | #define MT_NilSR (unsigned)0x2200 /* SR value for _MT_Nil() */
|
---|
13 | #define MT_DfPri (unsigned)0x4000 /* default task priority */
|
---|
14 |
|
---|
15 | #define MTF_RDY 0x0001 /* task ready to run (on MT_RdyQ) */
|
---|
16 | #define MTF_SWT 0x0002 /* task waiting on a semaphore */
|
---|
17 | #define MTF_RUN 0x0004 /* task running (MT_CurP) */
|
---|
18 | #define MTF_STP 0x0008 /* task to be stopped (waiting) */
|
---|
19 |
|
---|
20 | #define MTF_OCC 0x8000 /* TCB occupied */
|
---|
21 |
|
---|
22 | /* |
---|
23 |
|
---|
24 | */
|
---|
25 |
|
---|
26 | typedef long SEM; /* Semaphore */
|
---|
27 |
|
---|
28 | typedef struct _mt_msg { /* Message */
|
---|
29 |
|
---|
30 | struct _mt_msg *next; /* pointer to next message in queue */
|
---|
31 | SEM reply; /* reply semaphore */
|
---|
32 | long msize; /* message size */
|
---|
33 | long mdata; /* message data or pointer */
|
---|
34 | } MSG;
|
---|
35 |
|
---|
36 | typedef struct _mt_mbx { /* Mailbox */
|
---|
37 |
|
---|
38 | SEM mail; /* mail waiting semaphore */
|
---|
39 | SEM mutex; /* mutual exclusion semphore */
|
---|
40 | MSG *head; /* pointer to head of message queue */
|
---|
41 | MSG *tail; /* pointer to tail of message queue */
|
---|
42 | } MBOX;
|
---|
43 |
|
---|
44 | typedef struct _mt_tcb { /* Task Control Block */
|
---|
45 |
|
---|
46 | struct _mt_tcb *next; /* pointer to next TCB in queue */
|
---|
47 | struct _mt_tcb *fwd; /* pointer to next TCB in chain */
|
---|
48 | unsigned tid; /* task identifier */
|
---|
49 | unsigned pri; /* task priority */
|
---|
50 | long slice; /* time slice */
|
---|
51 | long reg[16]; /* registers */
|
---|
52 | long sp; /* stack pointer */
|
---|
53 | long pc; /* program counter */
|
---|
54 | unsigned sr; /* status register */
|
---|
55 | unsigned flags; /* task status flags */
|
---|
56 | long tos; /* pointer to top of stack */
|
---|
57 | } TCB;
|
---|
58 |
|
---|
59 | struct _mt_str { /* Multi-Tasker variable structure */
|
---|
60 |
|
---|
61 | TCB *TCBs; /* TCB chain pointer */
|
---|
62 | TCB *CurP; /* current TCB pointer */
|
---|
63 | TCB *RdyQ; /* ready queue pointer */
|
---|
64 | unsigned IDct; /* TCB ID counter */
|
---|
65 | };
|
---|
66 |
|
---|
67 | struct _mt_def { /* Multi-Tasker interface block */
|
---|
68 |
|
---|
69 | struct _mt_str *mtp; /* pointer to mt_str structure */
|
---|
70 | SEM *FCLK; /* pointer to SemFCLK */
|
---|
71 | SEM *Quit; /* pointer to SemQuit */
|
---|
72 | MBOX *Vid; /* pointer to MSG_Vid */
|
---|
73 | };
|
---|