annotate kernel/process.c3 @ 295:917eab04b8b7

Added disasm
author Windel Bouwman
date Thu, 28 Nov 2013 21:10:32 +0100
parents 534b94b40aa8
children 9417caea2eb3
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:
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
6 typedef struct {
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:
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
12 List<process_t> procs;
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
295
917eab04b8b7 Added disasm
Windel Bouwman
parents: 292
diff changeset
18 public 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 */
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
27 public func process_t* Create()
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