annotate kernel/process.c3 @ 299:674789d9ff37

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