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:
|
300
|
16 var process_t* init_pid = 0;
|
283
|
17 var int next_pid = 0;
|
|
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 {
|
300
|
30 // process_t* p = memory.Alloc(sizeof(process_t));
|
283
|
31 p->id = next_pid;
|
300
|
32 next_pid = next_pid + 1;
|
283
|
33 return p;
|
|
34 }
|
|
35
|
|
36
|
300
|
37 function void Kill(process_t* p)
|
283
|
38 {
|
|
39 // clean memory
|
|
40 }
|
|
41
|
300
|
42 function process_t* byId(int id)
|
292
|
43 {
|
|
44 // Perform lookup
|
|
45 return 0;
|
|
46 }
|
283
|
47
|