annotate kernel/process.c3 @ 283:c9781c73e7e2

Added first kernel files
author Windel Bouwman
date Fri, 15 Nov 2013 12:26:50 +0100
parents
children 534b94b40aa8
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;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
8 } process_t;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
9
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
10 // init is the root of all processes:
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
11 var process_t* init = 0;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
12 var int next_pid = 0;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
13
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
14 public func void Init()
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
15 {
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
16 next_pid = 0;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
17 init = Create();
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
18 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
19
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
20 /*
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
21 Create a new process.
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
22 */
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
23 public func process_t* Create()
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
24 {
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
25 process_t* p = memory.Alloc(sizeof(process_t));
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
26 p->id = next_pid;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
27 next_pid++;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
28 return p;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
29 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
30
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
31
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
32 public func void Kill(process_t* p)
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
33 {
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
34 // clean memory
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
35 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
36
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
37