MCPs -> Many Filthy _S Ps
[akaros.git] / kern / src / smp.c
index b6f2887..c368467 100644 (file)
@@ -62,15 +62,17 @@ void smp_idle(void)
        }
        assert(0);
 }
+
 #ifdef __CONFIG_EXPER_TRADPROC__
 /* For experiments with per-core schedulers (traditional).  This checks the
- * runqueue, and if there is something there, it runs in.  */
+ * runqueue, and if there is something there, it runs in.  Note this does
+ * nothing for whoever was running here.  Consider saving and restoring them,
+ * resetting current, etc. */
 void local_schedule(void)
 {
        struct per_cpu_info *my_info = &per_cpu_info[core_id()];
        struct proc *next_to_run;
 
-       printd("Core %d trying to schedule a _S process\n", core_id());
        spin_lock_irqsave(&my_info->runqueue_lock);
        next_to_run = TAILQ_FIRST(&my_info->runqueue);
        if (next_to_run)
@@ -78,8 +80,25 @@ void local_schedule(void)
        spin_unlock_irqsave(&my_info->runqueue_lock);
        if (!next_to_run)
                return;
-       assert(next_to_run->state = PROC_RUNNABLE_S);
-       proc_run(next_to_run);
-       assert(0); // don't reach this
+       assert(next_to_run->state == PROC_RUNNING_M); // FILTHY HACK
+       printd("Core %d trying to run proc %08p\n", core_id(), next_to_run);
+       void proc_run_hand(struct trapframe *tf, uint32_t src_id, void *p, void *a1,
+                          void *a2)
+       {
+               proc_run((struct proc*)p);
+       }
+       send_kernel_message(core_id(), proc_run_hand, (void*)next_to_run, 0, 0,
+                           KMSG_ROUTINE);
+       return;
 }
-#endif
+
+void local_schedule_proc(uint32_t core, struct proc *p)
+{
+       assert(core); // for sanity don't put them on core0 or any management core
+       struct per_cpu_info *my_info = &per_cpu_info[core];
+       spin_lock_irqsave(&my_info->runqueue_lock);
+       TAILQ_INSERT_TAIL(&my_info->runqueue, p, proc_link);
+       printd("SCHED: inserting proc %p on core %d\n", p, core);
+       spin_unlock_irqsave(&my_info->runqueue_lock);
+}
+#endif /* __CONFIG_EXPER_TRADPROC__ */