Implement sched_yield() with uthread_sched_yield() (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 12 Apr 2017 18:20:56 +0000 (14:20 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 3 May 2017 16:13:02 +0000 (12:13 -0400)
Rebuild glibc at your leisure.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Versions
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/parlib-compat.c
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sched_yield.c

index 3edee52..448973d 100644 (file)
@@ -6,6 +6,7 @@
 #include <libc-symbols.h>
 #include <ros/common.h>
 #include <ros/trapframe.h>
+#include <ros/syscall.h>
 #include <parlib/stdio.h>
 #include <parlib/assert.h>
 #include <parlib/spinlock.h>
@@ -105,3 +106,11 @@ void __cpu_relax_vc(uint32_t vcoreid)
        cpu_relax();
 }
 weak_alias(__cpu_relax_vc, cpu_relax_vc)
+
+void __uthread_sched_yield(void)
+{
+       /* In the off-chance we're called before parlib is available, we'll do the
+        * single-threaded, SCP yield. */
+       ros_syscall(SYS_proc_yield, TRUE, 0, 0, 0, 0, 0);
+}
+weak_alias(__uthread_sched_yield, uthread_sched_yield)
index be63f4d..16c6bb5 100644 (file)
 
 #include <errno.h>
 #include <sched.h>
-#include <ros/syscall.h>
+#include <parlib/uthread.h>
 
-/* Yield the processor.  */
-int
-__sched_yield (void)
+int __sched_yield(void)
 {
-  /* TRUE tells the kernel we simply want to let someone else process, and not
-   * that we are waiting on an event. */
-  return ros_syscall(SYS_proc_yield, TRUE, 0, 0, 0, 0, 0);
+       uthread_sched_yield();
+       return 0;
 }
 libc_hidden_def (__sched_yield)
 weak_alias (__sched_yield, sched_yield)