| 12345678910111213141516171819202122232425262728293031323334 |
- #ifndef CX_ZIVUOS_PROCESS_H_INCLUDED
- #define CX_ZIVUOS_PROCESS_H_INCLUDED
- #include <stdint.h>
- #include <stdbool.h>
- #include "models.h"
- typedef struct zv_process_s {
- zv_state_t state;
- zv_priority_t priority;
- zv_priority_t balance;
- zv_worker_t worker;
- zv_universal_t param;
- } zv_process_t;
- static inline bool zv_process_is_ready(zv_process_t *self) {
- return self->state == ZV_READY || self->state == ZV_INTERRUPTED;
- }
- static inline zv_priority_t _zv_process_calc_priority(zv_process_t *self) {
- if (ZV_LOWEST_PRIORITY - self->priority < self->balance) {
- return ZV_LOWEST_PRIORITY;
- }
- return self->priority + self->balance;
- }
- zv_result_t zv_process_change_param(zv_process_t *, zv_universal_t);
- zv_result_t zv_process_change_worker(zv_process_t *, zv_worker_t);
- #define ZV_COUNT_PROCESSES(X) ((sizeof(X) / sizeof(zv_process_t)))
- #endif
|