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