1 #include <parlib/parlib.h>
3 #include <ros/resource.h>
4 #include <ros/procdata.h>
7 #include <parlib/arch/arch.h>
10 #include <parlib/vcore.h>
11 #include <parlib/mcs.h>
12 #include <parlib/timing.h>
13 #include <parlib/assert.h>
14 #include <parlib/event.h>
15 #include <parlib/uthread.h>
17 void ghetto_vcore_entry(void);
19 struct schedule_ops ghetto_sched_ops = {
20 .sched_entry = ghetto_vcore_entry,
23 /* All MCP syscalls will spin instead of blocking */
24 static void __ros_syscall_spinon(struct syscall *sysc)
26 while (!(atomic_read(&sysc->flags) & (SC_DONE | SC_PROGRESS)))
30 int main(int argc, char** argv)
36 nr_vcores = max_vcores();
38 nr_vcores = atoi(argv[1]);
40 /* Inits a thread for us, though we won't use it. Just a hack to get into
41 * _M mode. Note this requests one vcore for us */
42 struct uthread dummy = {0};
43 uthread_2ls_init(&dummy, &ghetto_sched_ops);
46 /* Reset the blockon to be the spinner... This is really shitty. Any
47 * blocking calls after we become an MCP and before this will fail. This is
48 * just mhello showing its warts due to trying to work outside uthread.c */
49 ros_syscall_blockon = __ros_syscall_spinon;
51 vcore_request(nr_vcores - 1); /* since we already have 1 */
59 void ghetto_vcore_entry(void)
62 run_current_uthread();