annotate kernel/process.c3 @ 300:158068af716c

yafm
author Windel Bouwman
date Tue, 03 Dec 2013 18:00:22 +0100
parents 9417caea2eb3
children 6753763d3bec
rev   line source
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
1 module process;
300
Windel Bouwman
parents: 296
diff changeset
2
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
3 import memory;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
4 import kernel;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
5
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
6 // process type definition:
296
9417caea2eb3 Directorized some backend files
Windel Bouwman
parents: 295
diff changeset
7 type struct {
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
8 int id;
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
9 int status;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
10 } process_t;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
11
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
12 // Or, use this list structure:
296
9417caea2eb3 Directorized some backend files
Windel Bouwman
parents: 295
diff changeset
13 // List<process_t> procs;
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
14
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
15 // init is the root of all processes:
300
Windel Bouwman
parents: 296
diff changeset
16 var process_t* init_pid = 0;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
17 var int next_pid = 0;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
18
296
9417caea2eb3 Directorized some backend files
Windel Bouwman
parents: 295
diff changeset
19 function void init()
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
20 {
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
21 next_pid = 0;
300
Windel Bouwman
parents: 296
diff changeset
22 init_pid = Create();
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
23 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
24
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
25 /*
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
26 Create a new process.
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
27 */
296
9417caea2eb3 Directorized some backend files
Windel Bouwman
parents: 295
diff changeset
28 function process_t* Create()
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
29 {
300
Windel Bouwman
parents: 296
diff changeset
30 // process_t* p = memory.Alloc(sizeof(process_t));
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
31 p->id = next_pid;
300
Windel Bouwman
parents: 296
diff changeset
32 next_pid = next_pid + 1;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
33 return p;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
34 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
35
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
36
300
Windel Bouwman
parents: 296
diff changeset
37 function void Kill(process_t* p)
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
38 {
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
39 // clean memory
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
40 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
41
300
Windel Bouwman
parents: 296
diff changeset
42 function process_t* byId(int id)
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
43 {
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
44 // Perform lookup
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
45 return 0;
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
46 }
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
47