Repository navigation
Expand file tree
/
Copy pathThread.h
More file actions
executable file
·56 lines (45 loc) · 1.6 KB
/
Copy pathThread.h
File metadata and controls
executable file
·56 lines (45 loc) · 1.6 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
header Thread
uses System, List
const
SYSTEM_STACK_SIZE = 1000 -- in words
STACK_SENTINEL = 0x24242424 -- in ASCII, this is "$$$$"
functions
InitializeScheduler ()
Run (nextThread: ptr to Thread)
PrintReadyList ()
ThreadStartMain ()
ThreadFinish ()
FatalError (errorMessage: ptr to array of char)
SetInterruptsTo (newStatus: int) returns int
TimerInterruptHandler ()
external Switch (prevThread, nextThread: ptr to Thread)
external ThreadStartUp ()
var
readyList: List [Thread]
currentThread: ptr to Thread
mainThread: Thread
idleThread: Thread
threadsToBeDestroyed: List [Thread]
currentInterruptStatus: int
enum JUST_CREATED, READY, RUNNING, BLOCKED, UNUSED -- Thread status
enum ENABLED, DISABLED -- Interrupt status
class Thread
superclass Listable
fields
-- The first two fields are at fixed offsets, hardwired into Switch!
regs: array [13] of int -- Space for r2..r14
stackTop: ptr to void -- Space for r15 (system stack top ptr)
name: ptr to array of char
status: int -- JUST_CREATED, READY, RUNNING, BLOCKED, UNUSED
initialFunction: ptr to function (int) -- The thread's "main" function
initialArgument: int -- The argument to that function
systemStack: array [SYSTEM_STACK_SIZE] of int
methods
Init (n: ptr to array of char)
Fork (fun: ptr to function (int), arg: int)
Yield ()
Sleep ()
CheckOverflow ()
Print ()
endClass
endHeader