aboutsummaryrefslogtreecommitdiff
path: root/src/sys/schedule.c
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-02-01 20:36:30 -0700
committerChristian Cunningham <cc@localhost>2022-02-01 20:36:30 -0700
commit7d3884b5cfc282dbdfe5d9a22d8b2b343280b8af (patch)
treea3e5e5376c35cce48d1e2d907720646448c5e2ba /src/sys/schedule.c
parent98793badc1c1d3e4bfd735fdecd3d2d731701ab3 (diff)
Thread yield control to any other threads
Diffstat (limited to 'src/sys/schedule.c')
-rw-r--r--src/sys/schedule.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sys/schedule.c b/src/sys/schedule.c
index 6f2a72d..70aebb9 100644
--- a/src/sys/schedule.c
+++ b/src/sys/schedule.c
@@ -156,3 +156,16 @@ void* get_rthread_roffset(void)
{
return &scheduler.thread_queues[scheduler.rthread->priority].ready.roffset;
}
+
+void yield(void)
+{
+ struct Thread* rthread = scheduler.rthread;
+ if (rthread == &usrloopthread)
+ return;
+ unsigned char priority = rthread->priority;
+ struct ThreadRotBuffer* trb = &scheduler.thread_queues[priority].ready;
+ trb->roffset += 1;
+ trb->roffset %= TQUEUE_MAX;
+ trb->queue[trb->woffset++] = rthread;
+ trb->roffset %= TQUEUE_MAX;
+}