summaryrefslogtreecommitdiff
path: root/src/code/z_nulltask.c
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2022-06-03 20:43:30 +0100
committerGitHub <noreply@github.com>2022-06-03 15:43:30 -0400
commit1738b19d63d65afd01e1043a5359502ffef2e40e (patch)
tree28046b3903f20dfeb34c0bbddea44450ce3e2308 /src/code/z_nulltask.c
parentee5ac838b693f14710954f361ad91936975d00b7 (diff)
More documentation for sched.c (#1219)
* More documentation for sched.c * VI retrace -> vertical retrace, attempt to clarify comment in viconfig * Further review changes, fix inconsistent capitalization of PreNMI (PRENMI -> PreNMI) * Fix typo Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Change TaskSwapBuffer, change comment on OS_SC_DRAM_DLIST to unimplemented * Rename SchedContext/gSchedContext to Scheduler/gScheduler * Comments fixes Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Format Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Diffstat (limited to 'src/code/z_nulltask.c')
-rw-r--r--src/code/z_nulltask.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/code/z_nulltask.c b/src/code/z_nulltask.c
new file mode 100644
index 000000000..1f7dae689
--- /dev/null
+++ b/src/code/z_nulltask.c
@@ -0,0 +1,27 @@
+#include "global.h"
+
+/**
+ * Blocks the current thread until all queued scheduler tasks have completed.
+ */
+void Sched_FlushTaskQueue(void) {
+ OSScTask task;
+ OSMesgQueue queue;
+ OSMesg msg;
+
+ // Prepare a "NULL" task
+ task.next = NULL;
+ task.flags = OS_SC_NEEDS_RDP | OS_SC_NEEDS_RSP;
+ task.msgQueue = &queue;
+ task.msg = NULL;
+ task.framebuffer = NULL;
+ task.list.t.type = M_NULTASK;
+ osCreateMesgQueue(task.msgQueue, &msg, 1);
+
+ // Send it to and wake up the scheduler
+ osSendMesg(&gScheduler.cmdQueue, (OSMesg)&task, OS_MESG_BLOCK);
+ Sched_Notify(&gScheduler);
+
+ // Wait until the task has been processed, indicating that no task is
+ // running and the task queue is now empty.
+ osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
+}