annotate kernel/src/process.c3 @ 368:d2ddfe134c48

Remove yield from for python < 3.3
author Windel Bouwman
date Fri, 21 Mar 2014 11:21:50 +0100
parents b4ac28efcdf4
children 2ec730e45ea1
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:
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 301
diff changeset
16 var process_t* init_pid;
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 301
diff changeset
17 var int next_pid;
283
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 {
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
30 var process_t* p;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
31 //= memory.Alloc(sizeof(process_t));
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
32 p->id = next_pid;
300
Windel Bouwman
parents: 296
diff changeset
33 next_pid = next_pid + 1;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
34 return p;
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
300
Windel Bouwman
parents: 296
diff changeset
38 function void Kill(process_t* p)
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
39 {
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
40 // clean memory
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
41 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
42
300
Windel Bouwman
parents: 296
diff changeset
43 function process_t* byId(int id)
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
44 {
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
45 // Perform lookup
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
46 return 0;
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
47 }
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
48