283
|
1 module process;
|
|
2 import memory;
|
|
3 import kernel;
|
|
4
|
|
5 // process type definition:
|
296
|
6 type struct {
|
283
|
7 int id;
|
292
|
8 int status;
|
283
|
9 } process_t;
|
|
10
|
292
|
11 // Or, use this list structure:
|
296
|
12 // List<process_t> procs;
|
292
|
13
|
283
|
14 // init is the root of all processes:
|
|
15 var process_t* init = 0;
|
|
16 var int next_pid = 0;
|
|
17
|
296
|
18 function void init()
|
283
|
19 {
|
|
20 next_pid = 0;
|
|
21 init = Create();
|
|
22 }
|
|
23
|
|
24 /*
|
|
25 Create a new process.
|
|
26 */
|
296
|
27 function process_t* Create()
|
283
|
28 {
|
|
29 process_t* p = memory.Alloc(sizeof(process_t));
|
|
30 p->id = next_pid;
|
|
31 next_pid++;
|
|
32 return p;
|
|
33 }
|
|
34
|
|
35
|
|
36 public func void Kill(process_t* p)
|
|
37 {
|
|
38 // clean memory
|
|
39 }
|
|
40
|
292
|
41 public process_t* byId(int id)
|
|
42 {
|
|
43 // Perform lookup
|
|
44 return 0;
|
|
45 }
|
283
|
46
|