diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2024-01-20 15:47:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-20 20:47:00 -0300 |
| commit | 665353f3446db43d0efe0e9c6a9c80d16684da7a (patch) | |
| tree | 55f492f4661570636c9056561beb8e8fa6135d3d /src/code/z_nulltask.c | |
| parent | 732455fdef80ed641f0af30eb0e54d3a07ac876e (diff) | |
Irqmgr + scheduler Docs (#1527)
* irqmgr docs
* Sched_FlushTaskQueue
* scheduler docs
Diffstat (limited to 'src/code/z_nulltask.c')
| -rw-r--r-- | src/code/z_nulltask.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/code/z_nulltask.c b/src/code/z_nulltask.c new file mode 100644 index 000000000..b060e0639 --- /dev/null +++ b/src/code/z_nulltask.c @@ -0,0 +1,30 @@ +#include "scheduler.h" + +#include "macros.h" +#include "main.h" + +/** + * Blocks the current thread until all queued scheduler tasks have completed. + */ +void Sched_FlushTaskQueue(void) { + OSScTask task; + OSMesgQueue queue; + OSMesg msg[1]; + + // Prepare a "NULL" task + task.next = NULL; + task.flags = OS_SC_NEEDS_RDP | OS_SC_NEEDS_RSP; + task.msgQ = &queue; + task.msg = NULL; + task.framebuffer = NULL; + task.list.t.type = M_NULTASK; + osCreateMesgQueue(task.msgQ, msg, ARRAY_COUNT(msg)); + + // Send it to and wake up the scheduler + osSendMesg(&gScheduler.cmdQueue, (OSMesg)&task, OS_MESG_BLOCK); + Sched_SendNotifyMsg(&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); +} |
