| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef CX_ZIVUOS_TASK_H_INCLUDED
- #define CX_ZIVUOS_TASK_H_INCLUDED
- #include "systypes.h"
- /**
- * @brief That enum store task type.
- *
- * Task is container for more than one type of logic.
- * - Coroutine is function which run in loop. Could not being scheduled.
- * - Oneshot is coroutine which is executed only once.
- * - Process is task which could being scheduled.
- */
- typedef enum zv_task_type_e {
- ZV_COROUTINE_TASK,
- ZV_PROCESS_TASK,
- ZV_ONESHOT_TASK
- } zv_task_type_t;
- /**
- * @brief That enum store task state.
- */
- typedef enum zv_state_e {
- ZV_KILLED,
- ZV_RUNNING,
- ZV_READY,
- ZV_SLEEP
- } zv_state_t;
- /* That declaration is required for worker. */
- struct zv_kernel_s;
- /**
- * @brief That is worker, which is function for task.
- */
- typedef zv_state_t (*zv_worker_t) (struct zv_kernel_t *, zv_pid_t);
- typedef struct zv_coroutine_s {
- zv_worker_t worker;
- zv_universal_t param;
- } zv_coroutine_t;
- typedef struct zv_process_s {
- } zv_process_t;
- typedef struct zv_oneshot_s {
- zv_worker_t worker;
- zv_universal_t param;
- } zv_oneshot_t;
- typedef union zv_task_selector_u {
- zv_coroutine_t coroutine;
- zv_process_t process;
- zv_oneshot_t oneshot;
- } zv_task_selector_t;
- typedef struct zv_task_s {
- zv_pid_t pid;
- zv_state_t state;
- zv_priority_t priority;
- zv_task_type_t type;
- zv_task_selector_t selector;
- } zv_task_t;
- #endif
|