POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/include/core/sched.h
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 #ifndef __POK_SCHED_H__
00018 #define __POK_SCHED_H__
00019 
00020 #if defined (POK_NEEDS_SCHED) || defined (POK_NEEDS_THREADS)
00021 
00022 #include <types.h>
00023 #include <errno.h>
00024 #include <core/schedvalues.h>
00025 
00026 #ifdef POK_NEEDS_PARTITIONS
00027 extern uint8_t pok_current_partition;
00028 #define POK_SCHED_CURRENT_PARTITION pok_current_partition
00029 #endif
00030 
00031 
00032 extern uint32_t  current_thread;
00033 #define POK_SCHED_CURRENT_THREAD current_thread
00034 
00035 typedef enum
00036 {
00037   POK_STATE_STOPPED = 0,
00038   POK_STATE_RUNNABLE = 1,
00039   POK_STATE_WAITING = 2,
00040   POK_STATE_LOCK = 3,
00041   POK_STATE_WAIT_NEXT_ACTIVATION = 4,
00042   POK_STATE_DELAYED_START = 5
00043 } pok_state_t;
00044 
00045 void pok_sched_init (void); /* Initialize scheduling stuff */
00046 
00047 void pok_sched (void);      /* Main scheduling function, this function
00048                              * schedules everything
00049                              */
00050 
00051 /* Get priority function, return are made according to a scheduler */
00052 uint8_t pok_sched_get_priority_min (const pok_sched_t sched_type);
00053 uint8_t pok_sched_get_priority_max (const pok_sched_t sched_type);
00054 
00055 /* Scheduler election method */
00056 uint8_t pok_sched_election (void);
00057 uint32_t pok_sched_part_rr (const uint32_t ,const uint32_t,const uint32_t prev_thread,const uint32_t current_thread);
00058 uint32_t pok_sched_part_rms (const uint32_t ,const uint32_t,const uint32_t prev_thread,const uint32_t current_thread);
00059 
00060 /* Context switch functions */
00061 void pok_sched_context_switch (const uint32_t);
00062 void pok_partition_switch (void);
00063 
00064 /*
00065  * Functions to lock threads
00066  */
00067 void pok_sched_lock_thread (const uint32_t);
00068 void pok_sched_unlock_thread (const uint32_t);
00069 void pok_sched_lock_current_thread (void);
00070 void pok_sched_lock_current_thread_timed (const uint64_t time);
00071 void pok_sched_stop_thread (const uint32_t tid);
00072 void pok_sched_stop_self (void);
00073 pok_ret_t pok_sched_end_period ();
00074 
00075 #ifdef POK_NEEDS_PARTITIONS
00076 void pok_sched_activate_error_thread (void);
00077 #endif
00078 
00079 uint32_t pok_sched_get_current(uint32_t *thread_id);
00080 
00081 #endif /* POK_NEEDS.... */
00082 
00083 #endif /* !__POK_SCHED_H__ */
00084