POK(kernelpart)
sched.h
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 #ifndef __POK_SCHED_H__
18 #define __POK_SCHED_H__
19 
20 #if defined (POK_NEEDS_SCHED) || defined (POK_NEEDS_THREADS)
21 
22 #include <types.h>
23 #include <errno.h>
24 #include <core/schedvalues.h>
25 
26 #ifdef POK_NEEDS_PARTITIONS
27 extern uint8_t pok_current_partition;
28 #define POK_SCHED_CURRENT_PARTITION pok_current_partition
29 #endif
30 
31 
32 extern uint32_t current_thread;
33 #define POK_SCHED_CURRENT_THREAD current_thread
34 
35 typedef enum
36 {
37  POK_STATE_STOPPED = 0,
38  POK_STATE_RUNNABLE = 1,
39  POK_STATE_WAITING = 2,
40  POK_STATE_LOCK = 3,
41  POK_STATE_WAIT_NEXT_ACTIVATION = 4
42 } pok_state_t;
43 
44 void pok_sched_init (void); /* Initialize scheduling stuff */
45 
46 void pok_sched (void); /* Main scheduling function, this function
47  * schedules everything
48  */
49 
50 /* Get priority function, return are made according to a scheduler */
51 uint8_t pok_sched_get_priority_min (const pok_sched_t sched_type);
52 uint8_t pok_sched_get_priority_max (const pok_sched_t sched_type);
53 
54 /* Scheduler election method */
55 uint8_t pok_sched_election (void);
56 uint32_t pok_sched_part_rr (const uint32_t ,const uint32_t);
57 uint32_t pok_sched_part_rms (const uint32_t ,const uint32_t);
58 
59 /* Context switch functions */
60 void pok_sched_context_switch (const uint32_t);
61 void pok_partition_switch (void);
62 
63 /*
64  * Functions to lock threads
65  */
66 void pok_sched_lock_thread (const uint32_t);
67 void pok_sched_unlock_thread (const uint32_t);
68 void pok_sched_lock_current_thread (void);
69 void pok_sched_lock_current_thread_timed (const uint64_t time);
70 void pok_sched_stop_thread (const uint32_t tid);
71 void pok_sched_stop_self (void);
72 pok_ret_t pok_sched_end_period ();
73 
74 #ifdef POK_NEEDS_PARTITIONS
75 void pok_sched_activate_error_thread (void);
76 #endif
77 
78 uint32_t pok_sched_get_current(uint32_t *thread_id);
79 
80 #endif /* POK_NEEDS.... */
81 
82 #endif /* !__POK_SCHED_H__ */
83