comparison kernel/process.c3 @ 300:158068af716c

yafm
author Windel Bouwman
date Tue, 03 Dec 2013 18:00:22 +0100
parents 9417caea2eb3
children 6753763d3bec
comparison
equal deleted inserted replaced
299:674789d9ff37 300:158068af716c
1 module process; 1 module process;
2
2 import memory; 3 import memory;
3 import kernel; 4 import kernel;
4 5
5 // process type definition: 6 // process type definition:
6 type struct { 7 type struct {
10 11
11 // Or, use this list structure: 12 // Or, use this list structure:
12 // List<process_t> procs; 13 // List<process_t> procs;
13 14
14 // init is the root of all processes: 15 // init is the root of all processes:
15 var process_t* init = 0; 16 var process_t* init_pid = 0;
16 var int next_pid = 0; 17 var int next_pid = 0;
17 18
18 function void init() 19 function void init()
19 { 20 {
20 next_pid = 0; 21 next_pid = 0;
21 init = Create(); 22 init_pid = Create();
22 } 23 }
23 24
24 /* 25 /*
25 Create a new process. 26 Create a new process.
26 */ 27 */
27 function process_t* Create() 28 function process_t* Create()
28 { 29 {
29 process_t* p = memory.Alloc(sizeof(process_t)); 30 // process_t* p = memory.Alloc(sizeof(process_t));
30 p->id = next_pid; 31 p->id = next_pid;
31 next_pid++; 32 next_pid = next_pid + 1;
32 return p; 33 return p;
33 } 34 }
34 35
35 36
36 public func void Kill(process_t* p) 37 function void Kill(process_t* p)
37 { 38 {
38 // clean memory 39 // clean memory
39 } 40 }
40 41
41 public process_t* byId(int id) 42 function process_t* byId(int id)
42 { 43 {
43 // Perform lookup 44 // Perform lookup
44 return 0; 45 return 0;
45 } 46 }
46 47