uth: Track thread0 in uthread.c
[akaros.git] / user / parlib / thread0_sched.c
1 /* Copyright (c) 2015 Google, Inc.
2  * Barret Rhoden <brho@cs.berkeley.edu>
3  * See LICENSE for details.
4  *
5  * thread0_sched: a basic scheduler for thread0, used by SCPs without a
6  * multithreaded 2LS linked in.
7  *
8  * This is closely coupled with uthread.c */
9
10 #include <ros/arch/membar.h>
11 #include <parlib/arch/atomic.h>
12 #include <parlib/parlib.h>
13 #include <parlib/vcore.h>
14 #include <parlib/uthread.h>
15 #include <parlib/event.h>
16 #include <stdlib.h>
17
18 static void thread0_sched_entry(void);
19
20 /* externed into uthread.c */
21 struct schedule_ops thread0_2ls_ops = {
22         .sched_entry = thread0_sched_entry,
23 };
24
25 /* externed into uthread.c */
26 struct uthread *thread0_uth;
27
28 /* Thread0 scheduler ops (for processes that haven't linked in a full 2LS) */
29 static void thread0_sched_entry(void)
30 {
31         if (current_uthread)
32                 run_current_uthread();
33         else
34                 run_uthread(thread0_uth);
35 }