Debian Codegraph @

gcc/m2/gm2-libs-coroutines/Executive.def

raw
1 (* Executive.def provides a simple multitasking executive.
2
3 Copyright (C) 2002-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE Executive ;
28
29 EXPORT QUALIFIED SEMAPHORE, DESCRIPTOR,
30 InitProcess, KillProcess, Resume, Suspend, InitSemaphore,
31 Wait, Signal, WaitForIO, Ps, GetCurrentProcess,
32 RotateRunQueue, ProcessName, DebugProcess ;
33
34 TYPE
35 SEMAPHORE ; (* defines Dijkstras semaphores *)
36 DESCRIPTOR ; (* handle onto a process *)
37
38
39 (*
40 InitProcess - initializes a process which is held in the suspended
41 state. When the process is resumed it will start executing
42 procedure, p. The process has a maximum stack size of,
43 StackSize, bytes and its textual name is, Name.
44 The StackSize should be at least 5000 bytes.
45 *)
46
47 PROCEDURE InitProcess (p: PROC; StackSize: CARDINAL;
48 Name: ARRAY OF CHAR) : DESCRIPTOR ;
49
50
51 (*
52 KillProcess - kills the current process. Notice that if InitProcess
53 is called again, it might reuse the DESCRIPTOR of the
54 killed process. It is the responsibility of the caller
55 to ensure all other processes understand this process
56 is different.
57 *)
58
59 PROCEDURE KillProcess ;
60
61
62 (*
63 Resume - resumes a suspended process. If all is successful then the process, p,
64 is returned. If it fails then NIL is returned.
65 *)
66
67 PROCEDURE Resume (d: DESCRIPTOR) : DESCRIPTOR ;
68
69
70 (*
71 Suspend - suspend the calling process.
72 The process can only continue running if another process
73 Resumes it.
74 *)
75
76 PROCEDURE Suspend ;
77
78
79 (*
80 InitSemaphore - creates a semaphore whose initial value is, v, and
81 whose name is, Name.
82 *)
83
84 PROCEDURE InitSemaphore (v: CARDINAL; Name: ARRAY OF CHAR) : SEMAPHORE ;
85
86
87 (*
88 Wait - performs dijkstras P operation on a semaphore.
89 A process which calls this procedure will
90 wait until the value of the semaphore is > 0
91 and then it will decrement this value.
92 *)
93
94 PROCEDURE Wait (s: SEMAPHORE) ;
95
96
97 (*
98 Signal - performs dijkstras V operation on a semaphore.
99 A process which calls the procedure will increment
100 the semaphores value.
101 *)
102
103 PROCEDURE Signal (s: SEMAPHORE) ;
104
105
106 (*
107 WaitForIO - waits for an interrupt to occur on vector, VectorNo.
108 *)
109
110 PROCEDURE WaitForIO (VectorNo: CARDINAL) ;
111
112
113 (*
114 Ps - displays a process list together with process status.
115 *)
116
117 PROCEDURE Ps ;
118
119
120 (*
121 GetCurrentProcess - returns the descriptor of the current running
122 process.
123 *)
124
125 PROCEDURE GetCurrentProcess () : DESCRIPTOR ;
126
127
128 (*
129 RotateRunQueue - rotates the process run queue.
130 It does not call the scheduler.
131 *)
132
133 PROCEDURE RotateRunQueue ;
134
135
136 (*
137 ProcessName - displays the name of process, d, through
138 DebugString.
139 *)
140
141 PROCEDURE ProcessName (d: DESCRIPTOR) ;
142
143
144 (*
145 DebugProcess - gdb debug handle to enable users to debug deadlocked
146 semaphore processes.
147 *)
148
149 PROCEDURE DebugProcess (d: DESCRIPTOR) ;
150
151
152 END Executive.