Merge branch 'master' into proc-work
[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 <smp.h>
13
14 #include <assert.h>
15 #include <manager.h>
16 #include <process.h>
17 #include <workqueue.h>
18 #include <syscall.h>
19 #include <testing.h>
20 #include <kfs.h>
21
22 /*
23  * Currently, if you leave this function by way of env_run (process_workqueue
24  * that env_runs), you will never come back to where you left off, and the
25  * function will start from the top.  Hence the hack 'progress'.
26  */
27 void manager(void)
28 {
29         static uint8_t progress = 0;
30         env_t *envs[256];
31
32         switch (progress++) {
33                 case 0:
34                         envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
35                         proc_set_state(envs[0], PROC_RUNNABLE_S);
36                         env_run(envs[0]);
37                         break;
38                 case 1:
39                         panic("Do not panic");
40                         envs[0] = ENV_CREATE(roslib_proctests);
41                         envs[1] = ENV_CREATE(roslib_proctests);
42                         envs[2] = ENV_CREATE(roslib_proctests);
43                         envs[3] = ENV_CREATE(roslib_fptest);
44                         envs[4] = ENV_CREATE(roslib_fptest);
45                         envs[4] = ENV_CREATE(roslib_fptest);
46                         envs[5] = ENV_CREATE(roslib_hello);
47                         envs[6] = ENV_CREATE(roslib_null);
48                         //envs[6] = ENV_CREATE(roslib_measurements);
49                         env_run(envs[0]);
50                         break;
51                         #if 0
52                         #endif
53                 case 2:
54                         #if 0
55                         // reminder of how to spawn remotely
56                         for (int i = 0; i < 8; i++) {
57                                 envs[i] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
58                                 proc_set_state(envs[i], PROC_RUNNABLE_S);
59                                 smp_call_function_single(i, run_env_handler, envs[i], 0);
60                         }
61                         process_workqueue();
62                         #endif
63                 case 3:
64                 #if 0
65                 case 0:
66                         printk("Beginning Tests\n");
67                         test_run_measurements(progress-1);  // should never return
68                         break;
69                 case 1:
70                         envs[0] = ENV_CREATE(parlib_channel_test_client);
71                         envs[1] = ENV_CREATE(parlib_channel_test_server);
72                         smp_call_function_single(1, run_env_handler, envs[0], 0);
73                         smp_call_function_single(2, run_env_handler, envs[1], 0);
74                 case 2:
75                 case 3:
76                 case 4:
77                 case 5:
78                 case 6:
79                 case 7:
80                 case 8:
81                 case 9:
82                 case 10:
83                 case 11:
84                 case 12:
85                 case 13:
86                 case 14:
87                         test_run_measurements(progress-1);
88                         break;
89                 #endif
90                 default:
91                         printk("Manager Progress: %d\n", progress);
92                         schedule();
93         }
94         panic("If you see me, then you probably screwed up");
95
96         /*
97         printk("Servicing syscalls from Core 0:\n\n");
98         while (1) {
99                 process_generic_syscalls(&envs[0], 1);
100                 cpu_relax();
101         }
102         */
103         return;
104 }
105