Process state work, initial steps
[akaros.git] / kern / src / manager.c
1 /*
2  * Copyright (c) 2009 The Regents of the University of California
3  * Barret Rhoden <brho@cs.berkeley.edu>
4  * See LICENSE for details.
5  */
6
7 #ifdef __DEPUTY__
8 #pragma nodeputy
9 #endif
10
11 #include <arch/types.h>
12 #include <arch/apic.h>
13 #include <arch/smp.h>
14
15 #include <assert.h>
16 #include <manager.h>
17 #include <process.h>
18 #include <workqueue.h>
19 #include <syscall.h>
20 #include <testing.h>
21 #include <kfs.h>
22
23 /*
24  * Currently, if you leave this function by way of env_run (process_workqueue
25  * that env_runs), you will never come back to where you left off, and the
26  * function will start from the top.  Hence the hack 'progress'.
27  */
28 void manager(void)
29 {
30         static uint8_t progress = 0;
31         env_t *envs[256];
32
33         switch (progress++) {
34                 case 0:
35                         // careful, should check error codes returned from kfs_lookup_path
36                         //envs[0] = kfs_proc_create(kfs_lookup_path("roslib_spawn"));
37                         envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
38                         proc_set_state(envs[0], PROC_RUNNABLE_S);
39                         env_run(envs[0]);
40                         break;
41                 case 1:
42                         envs[0] = ENV_CREATE(roslib_proctests);
43                         envs[1] = ENV_CREATE(roslib_proctests);
44                         envs[2] = ENV_CREATE(roslib_proctests);
45                         envs[3] = ENV_CREATE(roslib_proctests);
46                         env_run(envs[0]);
47                         break;
48                         #if 0
49                         #endif
50                 case 2:
51                 case 3:
52                 #if 0
53                 case 0:
54                         printk("Beginning Tests\n");
55                         test_run_measurements(progress-1);  // should never return
56                         break;
57                 case 1:
58                 case 2:
59                 case 3:
60                 case 4:
61                 case 5:
62                 case 6:
63                 case 7:
64                 case 8:
65                 case 9:
66                 case 10:
67                 case 11:
68                 case 12:
69                 case 13:
70                 case 14:
71                         test_run_measurements(progress-1);
72                         break;
73                 #endif
74                 default:
75                         printk("Manager Progress: %d\n", progress);
76                         schedule();
77         }
78         panic("If you see me, then you probably screwed up");
79
80         /*
81         printk("Servicing syscalls from Core 0:\n\n");
82         while (1) {
83                 process_generic_syscalls(&envs[0], 1);
84                 cpu_relax();
85         }
86         */
87         return;
88 }
89