ISIX-RTOS - small operating system for ARM microcontrollers 1.2
|
00001 #ifndef _ISIX_PRV_SCHEDULER_H 00002 #define _ISIX_PRV_SCHEDULER_H 00003 00004 #include <prv/list.h> 00005 #include <isix/config.h> 00006 #include <isix/semaphore.h> 00007 #include <isix/scheduler.h> 00008 00009 //*-----------------------------------------------------------------------*/ 00010 //Definition of task ready list 00011 typedef struct task_ready_struct 00012 { 00013 prio_t prio; //Tasks group priority 00014 list_entry_t task_list; //List of task with some priority 00015 list_t inode; //List inode 00016 } task_ready_t; 00017 00018 /*-----------------------------------------------------------------------*/ 00019 //Task state 00020 #define TASK_READY (1<<0) //Task is ready 00021 #define TASK_SLEEPING (1<<1) //Task is sleeping 00022 #define TASK_WAITING (1<<2) //Task is waiting 00023 #define TASK_RUNNING (1<<3) //Task is running 00024 #define TASK_DEAD (1<<4) //Task is dead 00025 #define TASK_SEM_WKUP (1<<5) //After sem wakeup 00026 #ifdef ISIX_CONFIG_USE_MULTIOBJECTS 00027 #define TASK_WAITING_MULTIPLE (1<<6) //After sem wakeup 00028 #define TASK_MULTIPLE_WKUP (1<<7) //After wait for multiple wkup 00029 #endif 00030 /*-----------------------------------------------------------------------*/ 00031 00032 //Definition of task operations 00033 struct task_struct 00034 { 00035 unsigned long *top_stack; //Task stack ptr 00036 unsigned long *init_stack; //Initial value of stack for isix_free 00037 prio_t prio; //Priority of task 00038 uint8_t state; //stan watku 00039 tick_t jiffies; //Ticks when task wake up 00040 task_ready_t *prio_elem; //Pointer to own prio list 00041 list_t inode_sem; //Inode of semaphore 00042 sem_t *sem; //Pointer to waiting sem 00043 list_t inode; //List of tasks 00044 }; 00045 /*-----------------------------------------------------------------------*/ 00046 00047 #include <isix/types.h> 00048 #include <isix/scheduler.h> 00049 00050 /*-----------------------------------------------------------------------*/ 00051 //Current executed task 00052 extern struct task_struct *volatile isix_current_task; 00053 00054 /*-----------------------------------------------------------------------*/ 00055 //Current task pointer 00056 extern volatile bool isix_scheduler_running; 00057 00058 00059 /*-----------------------------------------------------------------------*/ 00060 //Scheduler function called on context switch in IRQ and Yield 00061 void isixp_schedule(void); 00062 00063 /*-----------------------------------------------------------------------*/ 00064 //Sched timer cyclic call 00065 void isixp_schedule_time(void); 00066 00067 /*-----------------------------------------------------------------------*/ 00068 //Lock scheduler and disable selected interrupt 00069 void isixp_enter_critical(void); 00070 00071 /*-----------------------------------------------------------------------*/ 00072 //Lock scheduler and reenable selected interrupt; 00073 void isixp_exit_critical(void); 00074 00075 /*-----------------------------------------------------------------------*/ 00076 //Add selected task to waiting list 00077 void isixp_add_task_to_waiting_list(struct task_struct *task, tick_t timeout); 00078 00079 /*-----------------------------------------------------------------------*/ 00080 //Add assigned task to ready list 00081 int isixp_add_task_to_ready_list(struct task_struct *task); 00082 00083 /*--------------------------------------------------------------*/ 00084 //Private add task to semaphore list 00085 void isixp_add_task_to_sem_list(list_entry_t *sem_list,struct task_struct *task); 00086 00087 /*-----------------------------------------------------------------------*/ 00088 //Delete task from ready list 00089 void isixp_delete_task_from_ready_list(struct task_struct *task); 00090 00091 /*-----------------------------------------------------------------------*/ 00092 //Add task list to delete 00093 void isixp_add_task_to_delete_list(struct task_struct *task); 00094 00095 /*-----------------------------------------------------------------------*/ 00096 00097 //Process base stack initialization 00098 unsigned long* isixp_task_init_stack(unsigned long *sp,task_func_ptr_t pfun,void *param); 00099 00100 /*-----------------------------------------------------------------------*/ 00101 00102 #endif 00103