📄 task.h
字号:
/* * task.h * * Copyright (C) STMicroelectronics Ltd. 1998 * * Task handling. */#ifndef __os20_task_h#define __os20_task_h #ifndef __size_t#define __size_ttypedef unsigned int size_t;#endif#include "ostime.h" /* needed for osclock_t */ #ifndef __workspace_t#define __workspace_ttypedef unsigned int* workspace_t;#endif #define OS20_PRIORITY_LEVELS 16#define MAX_USER_PRIORITY (OS20_PRIORITY_LEVELS - 1)#define MIN_USER_PRIORITY 0typedef enum{ task_state_created = 0, task_state_active = 1, task_state_terminated = 2, task_state_suspending = 3, task_state_suspended = 4} task_state_t;typedef enum{ task_flags_default = 0, //MM 16/01/06 task_flags_suspended = 1} task_flags_t;struct task_class_s;struct semaphore_s;struct task_s;typedef struct task_s{ workspace_t task_wptr; /* current stack pointer */ void (*task_iptr)(void*); /* initial instruction pointer */ struct task_s* task_link; /* link to next task on run/semaphore queue*/ int task_priority; /* task priority */ struct task_s* task_tlink; /* link to next task on timer queue*/ osclock_t task_timeout; /* task timeout if on timer queue */ struct semaphore_s* task_waiting; /* semaphore task is waiting on if in timeout as well*/ /*osclock_t task_timeleft;*/ /* remaining timeslice period */ struct task_s* task_next; /* next task in the creation list */ task_state_t task_state; /* current state */ char* task_stack_base; /* pointer to base of stack */ size_t task_stack_size; /* size of stack in bytes */ struct task_class_s* task_class; /* class of task */ void* task_data; /* per-task data */ struct semaphore_s* task_finished; /* task completed sync *///MDM: task profiling int id_task; /* id of the task *///MDM: task profiling}task_t;typedef int tdesc_t;typedef void (*task_onexit_function_t)(task_t*, int);int task_init (void (*function)(void* param), void* param, void* stack, size_t stack_size, task_t* task, tdesc_t* tdesc, int priority, const char* name, task_flags_t flags);task_t* task_create (void (*function)(void* param), void* param, size_t stack_size, int priority, const char* name, task_flags_t flags);task_t* task_id (void);//MDM: task profilingint get_task_id (void);//MDM: task profilingvoid task_reschedule (void);int task_priority_set (task_t* Task, int NewPriority);int task_priority (task_t* Task);void task_delay (unsigned int Delay);void task_delay_until (unsigned int ExitTime);void task_lock (void);void task_unlock (void);int task_delete(task_t *task);void* task_stack_base(task_t*);size_t task_stack_size(task_t*);size_t task_stack_used(task_t*);task_t* task_list_head (void);task_t* task_list_next(task_t*);const char* task_name(task_t*);osclock_t task_time(task_t*);void* task_data(task_t* task);void* task_data_set(task_t* task, void* data);void task_exit (int param);int task_wait (task_t** task_list, int ntasks, const osclock_t* timeout);task_onexit_function_t task_onexit_set (task_onexit_function_t function);int task_suspend(task_t* Task);int task_resume(task_t* Task);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -