sgdk
task.h File Reference

User task support. More...

#include "task_cst.h"

Go to the source code of this file.

Functions

void TSK_userSet (VoidCallback *task)
 Configure the user task callback function.
Must be set with a not NULL callback before calling any TSK_xxx functions.
void TSK_stop ()
 Stop the user task.
This has the same effect than using TSK_setUser(NULL).
void TSK_userYield (void)
 Yield from supervisor task to user task. The user task will resume and will use all the available CPU time until the next vertical blanking interrupt, that will resume the supervisor task.
bool TSK_superPend (s16 wait)
 Block supervisor task and resume user task. Supervisor task will not resume execution until TSK_superPost() is called from user task or a timeout happens..
void TSK_superPost (bool immediate)
 Resume a blocked supervisor task. Must be called from user task.

Detailed Description

User task support.

Date:
12/2021
Author:
doragasu

This module allows assigning a function that will run as an user task. CPU time is given to that function in several ways:

  • When the supervisor task calls TSK_userYield(), the user task executes immediately until the next VBlank interrupt. Then supervisor task is resumed.
  • When the supervisor task call TSK_superPend(), the user task executes immediately until one of the following happens: a) The user task calls TSK_superPend(). b) The timeout specified in TSK_superPost() expires.

For the scheduler to work, VBlank interrupts must be enabled.

These functions are implemented in task.s


Function Documentation

bool TSK_superPend ( s16  wait)

Block supervisor task and resume user task. Supervisor task will not resume execution until TSK_superPost() is called from user task or a timeout happens..

Parameters:
waitMaximum number of frames to wait while blocking. Use TSK_PEND_FOREVER for an infinite wait, or a positive number (greater than 0) for a specific number of frames.
Returns:
false if task was awakened from user task, or true if timeout occurred.
void TSK_superPost ( bool  immediate)

Resume a blocked supervisor task. Must be called from user task.

Parameters:
immediateIf true, immediately causes a context switch to supervisor task. If false, context switch will not occur until the VBLANK interrupt.
void TSK_userSet ( VoidCallback *  task)

Configure the user task callback function.
Must be set with a not NULL callback before calling any TSK_xxx functions.

Parameters:
taskA function pointer to the user task (or NULL to disable multitasking).
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines