pthread: Allow new threads in forked children
[akaros.git] / user / parlib / thread0_sched.c
index 5c7e97d..ca1d0a0 100644 (file)
@@ -16,6 +16,7 @@
 #include <parlib/arch/trap.h>
 #include <parlib/ros_debug.h>
 #include <stdlib.h>
+#include <sys/fork_cb.h>
 
 static void thread0_sched_init(void);
 static void thread0_sched_entry(void);
@@ -31,6 +32,8 @@ static void thread0_sync_destroy(uth_sync_t *s);
 static void thread0_sync_enqueue(struct uthread *uth, uth_sync_t *s);
 static struct uthread *thread0_sync_get_next(uth_sync_t *s);
 static bool thread0_sync_get_uth(uth_sync_t *s, struct uthread *uth);
+static void thread0_sync_swap(uth_sync_t *a, uth_sync_t *b);
+static bool thread0_sync_is_empty(uth_sync_t *s);
 
 /* externed into uthread.c */
 struct schedule_ops thread0_2ls_ops = {
@@ -48,6 +51,8 @@ struct schedule_ops thread0_2ls_ops = {
        .sync_enqueue = thread0_sync_enqueue,
        .sync_get_next = thread0_sync_get_next,
        .sync_get_uth = thread0_sync_get_uth,
+       .sync_swap = thread0_sync_swap,
+       .sync_is_empty = thread0_sync_is_empty,
 };
 
 struct schedule_ops *sched_ops __attribute__((weak)) = &thread0_2ls_ops;
@@ -70,6 +75,14 @@ void thread0_handle_syscall(struct event_msg *ev_msg,
        thread0_info.is_blocked = FALSE;
 }
 
+static void thread0_pre_fork(void)
+{
+}
+
+static void thread0_post_fork(pid_t ret)
+{
+}
+
 void thread0_sched_init(void)
 {
        int ret;
@@ -83,6 +96,8 @@ void thread0_sched_init(void)
        sysc_evq = get_eventq(EV_MBOX_BITMAP);
        sysc_evq->ev_flags = EVENT_INDIR | EVENT_WAKEUP;
        uthread_2ls_init(thread0_uth, thread0_handle_syscall, NULL);
+       pre_fork_2ls = thread0_pre_fork;
+       post_fork_2ls = thread0_post_fork;
 }
 
 /* Thread0 scheduler ops (for processes that haven't linked in a full 2LS) */
@@ -209,3 +224,12 @@ static bool thread0_sync_get_uth(uth_sync_t *s, struct uthread *uth)
        }
        return FALSE;
 }
+
+static void thread0_sync_swap(uth_sync_t *a, uth_sync_t *b)
+{
+}
+
+static bool thread0_sync_is_empty(uth_sync_t *s)
+{
+       return !thread0_info.is_blocked;
+}