PIC24 Support Libraries
|
Files | |
file | esos_task.h |
Data Structures | |
struct | stSemaphore |
struct | ESOS_TASK_HANDLE |
Initialization | |
#define | __ESOS_INIT_TASK(TaskHandle) |
Querying the state of a task | |
#define | ESOS_IS_TASK_INITED(TaskHandle) |
#define | ESOS_IS_TASK_SLEEPING(TaskHandle) |
#define | ESOS_IS_TASK_KILLED(TaskHandle) |
#define | ESOS_IS_TASK_WAITING(TaskHandle) |
#define | ESOS_IS_TASK_ENDED(TaskHandle) |
Declaration and definition | |
#define | ESOS_USER_TASK(taskname) |
#define | ESOS_CHILD_TASK(taskname, ...) |
#define | ESOS_TASK_BEGIN() |
#define | ESOS_TASK_END() |
#define | ESOS_TASK_GET_TASK_HANDLE() |
Calling an ESOS task | |
#define | ESOS_SCHEDULE_TASK(pfnThread) |
Blocked waits | |
#define | ESOS_TASK_WAIT_UNTIL(condition) |
#define | ESOS_TASK_WAIT_WHILE(cond) |
#define | ESOS_TASK_WAIT_TICKS(u32_duration) |
Tasks and child tasks | |
#define | ESOS_TASK_WAIT_THREAD(pfnChild, ...) |
#define | ESOS_TASK_SPAWN_AND_WAIT(pstChild, pfnChild, ...) |
#define | ESOS_ALLOCATE_CHILD_TASK(pstName) |
Sleeping, killing, exiting and restarting tasks | |
#define | ESOS_TASK_SLEEP() |
#define | ESOS_TASK_RESTART() |
#define | ESOS_TASK_EXIT() |
#define | ESOS_WAKE_TASK(TaskHandle) |
#define | ESOS_KILL_TASK(TaskHandle) |
#define | ESOS_RESTART_TASK(TaskHandle) |
Yielding from an ESOS task | |
#define | ESOS_TASK_YIELD() |
Task semaphores | |
#define | ESOS_SEMAPHORE(semaphoreName) |
#define | ESOS_INIT_SEMAPHORE(semaphoreName, i16_val) |
#define | ESOS_TASK_WAIT_SEMAPHORE(semaphoreName, i16_val) |
#define | ESOS_SIGNAL_SEMAPHORE(semaphoreName, i16_val) |
#define __ESOS_INIT_TASK | ( | TaskHandle | ) |
Initialize an ESOS task.
Initializes an ESOS task. Initialization must be done prior to starting to execute the task.
TaskHandle | The ESOS_TASK_HANDLE of the task to be initialized |
Definition at line 143 of file esos_task.h.
#define ESOS_ALLOCATE_CHILD_TASK | ( | pstName | ) |
Allocates a child task storage structure in the local stack frame.
This macro spawns a child ESOS task and waits until it exits. The macro can only be used within an ESOS task.
pstName | Name of variable to represent the allocated child task structure |
Definition at line 448 of file esos_task.h.
#define ESOS_CHILD_TASK | ( | taskname, | |
... | |||
) |
Declaration of an ESOS child task – a task spawned by another ESOS task (a.k.a. the parent task)
This macro is used to declare an ESOS child task. All ESOS child tasks must be declared with this macro. This macro relies on the compiler's ability to handle variadic arguments. GCC does this just fine. Other compilers may not work.
taskname | The name by which you wish for the child task to be known. In reality, this name is the name of a C function implementing the ESOS child task. |
... | (OPTIONAL) Any arguments to pass to the the child task |
Definition at line 247 of file esos_task.h.
Referenced by esos_pic24_configI2C1().
#define ESOS_INIT_SEMAPHORE | ( | semaphoreName, | |
i16_val | |||
) |
Initialize a semaphore
This macro initializes a semaphore with a value for the counter. Internally, the semaphores use an "signed 16 bit integer" to represent the counter, and therefore the "count" argument should be between -32768 and +32767
semaphoreName | An ESOS semaphore created by ESOS_SEMAPHORE |
i16_val | (int16_t) The initial count of the semaphore. |
Definition at line 650 of file esos_task.h.
#define ESOS_IS_TASK_ENDED | ( | TaskHandle | ) |
Determines if a task is inactive/ended. Tasks in this state are subject to culling by the ESOS scheduler at some point in future.
TaskHandle | The ESOS_TASK_HANDLE of the task being queried |
Definition at line 205 of file esos_task.h.
#define ESOS_IS_TASK_INITED | ( | TaskHandle | ) |
Is ESOS task structure initialized?.
Checks to see of the ESOS task structure is initialized. Initialization must be done prior to starting to execute the task. In reality, this checks to see if a task structure is available since a 'running' task structure will appear to be uninitialized since its state will not be NULL, ZERO, or whatever our implementation of uses as the initial state.
TaskHandle | The ESOS_TASK_HANDLE of the task being queried |
Definition at line 167 of file esos_task.h.
Referenced by esos_GetFreeChildTaskStruct().
#define ESOS_IS_TASK_KILLED | ( | TaskHandle | ) |
Determines if a task is slated to be killed at its next execution.
TaskHandle | The ESOS_TASK_HANDLE of the task being queried |
Definition at line 185 of file esos_task.h.
#define ESOS_IS_TASK_SLEEPING | ( | TaskHandle | ) |
Determines if a task is currently sleeping
TaskHandle | The ESOS_TASK_HANDLE of the task being queried |
Definition at line 176 of file esos_task.h.
#define ESOS_IS_TASK_WAITING | ( | TaskHandle | ) |
Determines if a task is waiting to run/blocked by some condition.
TaskHandle | The ESOS_TASK_HANDLE of the task being queried |
Definition at line 194 of file esos_task.h.
#define ESOS_KILL_TASK | ( | TaskHandle | ) |
Kill an scheduled ESOS task.
This macro will cause the target task to "die" (exit) at its next scheduled execution. The target task will not execute any more instructions.
TaskHandle | The ESOS_TASK_HANDLE of the task to kill |
Definition at line 547 of file esos_task.h.
#define ESOS_RESTART_TASK | ( | TaskHandle | ) |
Restart a scheduled ESOS task
This macro will cause the target task to "restart" (run from the beginning as if it were just created) at its next scheduled execution.
TaskHandle | The ESOS_TASK_HANDLE of the task to kill |
Definition at line 565 of file esos_task.h.
#define ESOS_SCHEDULE_TASK | ( | pfnThread | ) |
Schedule an ESOS task.
This function schedules an ESOS task. The return value of the function is non-zero if the ESOS task is running or zero if the ESOS task has exited.
pfnThread | The call to the C function implementing the ESOS task to be scheduled |
Definition at line 314 of file esos_task.h.
#define ESOS_SEMAPHORE | ( | semaphoreName | ) |
Declare (and create storage for) an ESOS counting semaphore
semaphoreName | The name by which the semaphore is to be known |
Definition at line 632 of file esos_task.h.
#define ESOS_SIGNAL_SEMAPHORE | ( | semaphoreName, | |
i16_val | |||
) |
Signal a semaphore
This macro carries out the "signal" operation on the semaphore. The signal operation increments the counter inside the semaphore, which eventually will cause waiting protothreads to continue executing.
semaphoreName | An ESOS semaphore created by ESOS_SEMAPHORE |
i16_val | (int16_t) number to decrement semaphore value |
Definition at line 687 of file esos_task.h.
#define ESOS_TASK_BEGIN | ( | ) |
Declare the start of an ESOS task inside the C function implementing the ESOS task.
This macro is used to declare the starting point of a ESOS task. It should be placed at the start of the function in which the ESOS task runs. All C statements above the ESOS_TASK_BEGIN() invokation will be executed each time the ESOS task is scheduled.
Definition at line 260 of file esos_task.h.
Referenced by ESOS_CHILD_TASK(), esos_pic24_configI2C1(), and ESOS_USER_TASK().
#define ESOS_TASK_END | ( | ) |
Declare the end of an ESOS task.
This macro is used for declaring that an ESOS task ends. It must always be used together with a matching ESOS_TASK_BEGIN() macro.
Definition at line 272 of file esos_task.h.
Referenced by ESOS_CHILD_TASK(), and esos_pic24_configI2C1().
#define ESOS_TASK_EXIT | ( | ) |
Exit the current ESOS task.
This macro causes the current ESOS task to exit. If the ESOS task was spawned by another ESOS task, the parent ESOS task will become unblocked and can continue to run.
Definition at line 513 of file esos_task.h.
#define ESOS_TASK_GET_TASK_HANDLE | ( | ) |
Retrieve the task handle for the current task.
This macro gets the task handle for the current task. Useful if the current task wishes to give its handle to some other task so that the other task can manipulate the current task externally.
Definition at line 290 of file esos_task.h.
#define ESOS_TASK_RESTART | ( | ) |
Restart the current ESOS task.
This macro will block the current and cause the task to restart its execution at the place of the ESOS_TASK_BEGIN() call at its next scheduled execution time.
Definition at line 494 of file esos_task.h.
#define ESOS_TASK_SLEEP | ( | ) |
Put the current task to sleep.
This macro will cause the current task to "sleep" (block) until the task is awakened. The current task will not execute until it is explicitly wakened by some task caliing ESOS_WAKE_TASK with the target task's identifier. The sleeping task will resume execution at the instruction following the ESOS_TASK_SLEEP().
Definition at line 479 of file esos_task.h.
#define ESOS_TASK_SPAWN_AND_WAIT | ( | pstChild, | |
pfnChild, | |||
... | |||
) |
This macro initializes an ESOS child task structure, calls the child task and blocks the parent task until the child exits exits. The macro can only be used within an ESOS task.
pstChild | Pointer to the child ESOS task's control structure. |
pfnChild | Pointer to the child task function |
... | Arguments to the child task (if they exist) |
Definition at line 436 of file esos_task.h.
#define ESOS_TASK_WAIT_SEMAPHORE | ( | semaphoreName, | |
i16_val | |||
) |
Wait for a semaphore
This macro carries out the "wait" operation on the semaphore. The wait operation causes the current ESOS task to block while the counter is zero. When the counter reaches a value larger than zero, the task will continue.
semaphoreName | An ESOS semaphore created by ESOS_SEMAPHORE |
i16_val | (int16_t) number to decrement semaphore value |
Definition at line 667 of file esos_task.h.
#define ESOS_TASK_WAIT_THREAD | ( | pfnChild, | |
... | |||
) |
Block and wait until a child ESOS task completes.
This macro schedules a child ESOS task. The current ESOS task will block until the child ESOS task completes.
pfnChild | Pointer to the child task function |
... | Arguments to the child task (if they exist) |
Definition at line 419 of file esos_task.h.
#define ESOS_TASK_WAIT_TICKS | ( | u32_duration | ) |
Block and wait for a period of time/ticks
This function blocks and waits for the duration of time requested.
u32_duration | Number of system ticks (currently milliseconds) to block |
Definition at line 376 of file esos_task.h.
#define ESOS_TASK_WAIT_UNTIL | ( | condition | ) |
Block and wait until condition is true.
This macro blocks the ESOS task until the specified condition is true.
condition | The condition. |
Definition at line 336 of file esos_task.h.
Referenced by esos_pic24_configI2C1().
#define ESOS_TASK_WAIT_WHILE | ( | cond | ) |
Block and wait while condition is true.
This function blocks and waits while the specified condition is true.
cond | The condition. |
Definition at line 364 of file esos_task.h.
Referenced by ESOS_CHILD_TASK(), and esos_pic24_configI2C1().
#define ESOS_TASK_YIELD | ( | ) |
Yield the current ESOS task.
This function will yield the ESOS task IMMEDIATELY, thereby allowing other processing to take place in the system. The task will resume at the next instruction at its next invocation by the scheduler. (Of course, another task may "kill" it in the meantime and the task will not run again.)
Definition at line 590 of file esos_task.h.
#define ESOS_USER_TASK | ( | taskname | ) |
Declaration of an ESOS task.
This macro is used to declare an ESOS task. All ESOS tasks must be declared with this macro.
taskname | The name by which you wish for the user task to be known. In reality, this name is the name of the C function implementing the ESOS task. Therefore, your task names must be unique and adhere to C language naming restrictions. |
Definition at line 228 of file esos_task.h.
#define ESOS_WAKE_TASK | ( | TaskHandle | ) |
Wake up a sleeping ESOS task.
This macro will cause the target task to "wake" (resume) at its next opportunity. The sleeping task will resume execution at the instruction following the ESOS_TASK_SLEEP that initially put the task to sleep.
TaskHandle | The ESOS_TASK_HANDLE of the task to wake up. |
Definition at line 534 of file esos_task.h.