Adding SharC annotations. Type checker off
[akaros.git] / kern / src / manager.c
index be5306e..71570fc 100644 (file)
@@ -4,61 +4,91 @@
  * See LICENSE for details.
  */
 
-#ifdef __DEPUTY__
-#pragma nodeputy
+#ifdef __SHARC__
+#pragma nosharc
 #endif
 
-#include <arch/types.h>
+#include <ros/common.h>
 #include <smp.h>
 
 #include <assert.h>
 #include <manager.h>
 #include <process.h>
+#include <schedule.h>
 #include <workqueue.h>
 #include <syscall.h>
 #include <testing.h>
 #include <kfs.h>
+#include <stdio.h>
+#include <timing.h>
 
 /*
- * Currently, if you leave this function by way of env_run (process_workqueue
- * that env_runs), you will never come back to where you left off, and the
+ * Currently, if you leave this function by way of proc_run (process_workqueue
+ * that proc_runs), you will never come back to where you left off, and the
  * function will start from the top.  Hence the hack 'progress'.
  */
 void manager(void)
 {
-       static uint8_t progress = 0;
-       env_t *envs[256];
+       static uint8_t RACY progress = 0;
+       struct proc *envs[256];
+       struct proc *p ;
 
        switch (progress++) {
                case 0:
+                       // Here's how to do a multicored/parallel process:
+                       p = kfs_proc_create(kfs_lookup_path("roslib_mhello"));
+                       // being proper and all:
+                       proc_set_state(p, PROC_RUNNABLE_S);
+                       proc_set_state(p, PROC_RUNNING_S);
+                       proc_set_state(p, PROC_RUNNABLE_M);
+       
+                       // set vcoremap with dispatch plan.  usually done by schedule()
+                       spin_lock_irqsave(&p->proc_lock);
+                       p->num_vcores = 5; // assuming 5 are free, this is just an example
+                       spin_lock(&idle_lock); // need to grab the cores
+                       for (int i = 0; i < 5; i++) {
+                               // grab the last one on the list
+                               p->vcoremap[i] = idlecoremap[num_idlecores-1];
+                               num_idlecores--;
+                       }
+                       spin_unlock(&idle_lock);
+                       spin_unlock_irqsave(&p->proc_lock);
+                       proc_run(p);
+                       udelay(5000000);
+                       printk("Killing p\n");
+                       proc_destroy(p);
+                       printk("Killed p\n");
+                       udelay(1000000);
+                       panic("This is okay");
+                       break;
+               case 1:
                        envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
                        proc_set_state(envs[0], PROC_RUNNABLE_S);
-                       env_run(envs[0]);
+                       proc_run(envs[0]);
                        break;
        #ifdef __i386__
-               case 1:
+               case 2:
                        panic("Do not panic");
-                       envs[0] = ENV_CREATE(parlib_channel_test_client);
-                       envs[1] = ENV_CREATE(parlib_channel_test_server);
+                       envs[0] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_client"));
+                       envs[1] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_server"));
                        smp_call_function_single(1, run_env_handler, envs[0], 0);
                        smp_call_function_single(2, run_env_handler, envs[1], 0);
                        break;
-               case 2:
                case 3:
        #else // sparc
-               case 1:
+               case 2:
                        panic("Do not panic");
-                       envs[0] = ENV_CREATE(roslib_proctests);
-                       envs[1] = ENV_CREATE(roslib_proctests);
-                       envs[2] = ENV_CREATE(roslib_proctests);
-                       envs[3] = ENV_CREATE(roslib_fptest);
-                       envs[4] = ENV_CREATE(roslib_fptest);
-                       envs[4] = ENV_CREATE(roslib_fptest);
-                       envs[5] = ENV_CREATE(roslib_hello);
-                       envs[6] = ENV_CREATE(roslib_null);
-                       env_run(envs[0]);
+                       envs[0] = kfs_proc_create(kfs_lookup_path("roslib_proctests"));
+                       envs[1] = kfs_proc_create(kfs_lookup_path("roslib_proctests"));
+                       envs[2] = kfs_proc_create(kfs_lookup_path("roslib_proctests"));
+                       envs[3] = kfs_proc_create(kfs_lookup_path("roslib_fptest"));
+                       envs[4] = kfs_proc_create(kfs_lookup_path("roslib_fptest"));
+                       envs[4] = kfs_proc_create(kfs_lookup_path("roslib_fptest"));
+                       envs[5] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
+                       envs[6] = kfs_proc_create(kfs_lookup_path("roslib_null"));
+                       proc_run(envs[0]);
                        break;
-               case 2:
+               case 3:
                        #if 0
                        // reminder of how to spawn remotely
                        for (int i = 0; i < 8; i++) {
@@ -68,7 +98,6 @@ void manager(void)
                        }
                        process_workqueue();
                        #endif
-               case 3:
        #endif
 
                #if 0
@@ -77,8 +106,8 @@ void manager(void)
                        test_run_measurements(progress-1);  // should never return
                        break;
                case 5:
-                       envs[0] = ENV_CREATE(parlib_channel_test_client);
-                       envs[1] = ENV_CREATE(parlib_channel_test_server);
+                       envs[0] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_client"));
+                       envs[1] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_server"));
                        smp_call_function_single(1, run_env_handler, envs[0], 0);
                        smp_call_function_single(2, run_env_handler, envs[1], 0);
                case 6:
@@ -119,4 +148,3 @@ void manager(void)
        */
        return;
 }
-