]> rtime.felk.cvut.cz Git - rtems-pluggable-edf.git/blob - rtems-omk-template/appfoo/scheduler_edf.h
dcad0bace0797aac98df14c9e287dc9c921ed8b1
[rtems-pluggable-edf.git] / rtems-omk-template / appfoo / scheduler_edf.h
1 #ifndef _SCHEDULER_EDF_H
2 #define _SCHEDULER_EDF_H
3
4 #include <rtems/score/scheduler.h>
5 #include <rtems/score/chain.h>
6 #include <rtems/score/thread.h>
7 #include "edf_types.h"
8
9 // keeps the ready queue for EDF
10 EDF_Chain_Control _Thread_Ready_EDF_chain;
11
12 #define SCHEDULER_EDF_ENTRY_POINTS \
13         { \
14         _Scheduler_edf_Initialize,    /* initialize entry point */ \
15         _Scheduler_edf_Schedule,      /* schedule entry point */ \
16         _Scheduler_edf_Yield,         /* yield entry point */ \
17         _Scheduler_edf_Block,         /* block entry point */ \
18         _Scheduler_edf_Unblock,       /* unblock entry point */ \
19         _Scheduler_edf_Allocate,      /* allocate entry point */ \
20         _Scheduler_edf_Free,          /* free entry point */ \
21         _Scheduler_edf_Update,        /* update entry point */ \
22         _Scheduler_edf_Enqueue,       /* enqueue entry point */ \
23         _Scheduler_edf_Enqueue_first, /* enqueue_first entry point */ \
24         _Scheduler_edf_Extract        /* extract entry point */ \
25         }
26
27
28
29 /**
30  * This routine initializes the priority scheduler.
31  */
32 void _Scheduler_edf_Initialize(void);
33
34 /**
35  *  This routine removes @a the_thread from the scheduling decision, 
36  *  that is, removes it from the ready queue.  It performs
37  *  any necessary scheduling operations including the selection of
38  *  a new heir thread.
39  *
40  *  @param[in] the_thread is the thread to be blocked
41  */
42 void _Scheduler_edf_Block( 
43   Thread_Control    *the_thread 
44 );
45
46 /**
47  *  This kernel routine sets the heir thread to be the next ready thread 
48  *  by invoking the_scheduler->ready_queue->operations->first().
49  */
50 void _Scheduler_edf_Schedule(void);
51
52 /**
53  *  This routine allocates @a the_thread->scheduler.
54  *
55  *  @param[in] the_thread is the thread the scheduler is allocating
56  *             management memory for
57  */
58 void * _Scheduler_edf_Allocate(
59   Thread_Control      *the_thread
60 );
61
62 /**
63  *  This routine frees @a the_thread->scheduler.
64  *
65  *  @param[in] the_thread is the thread whose scheduler specific information
66  *             will be deallocated.
67  */
68 void _Scheduler_edf_Free(
69   Thread_Control      *the_thread
70 );
71
72 /**
73  *  This routine updates @a the_thread->scheduler based on @a the_scheduler 
74  *  structures and thread state.
75  *
76  *  @param[in] the_thread will have its scheduler specific information
77  *             structure updated.
78  */
79 void _Scheduler_edf_Update(
80   Thread_Control      *the_thread
81 );
82
83 /**
84  *  This routine adds @a the_thread to the scheduling decision, 
85  *  that is, adds it to the ready queue and 
86  *  updates any appropriate scheduling variables, for example the heir thread.
87  *
88  *  @param[in] the_thread will be unblocked
89  */
90 void _Scheduler_edf_Unblock(
91   Thread_Control    *the_thread 
92 );
93
94 /**
95  *  This routine is invoked when a thread wishes to voluntarily
96  *  transfer control of the processor to another thread in the queue.
97  *
98  *  This routine will remove the running THREAD from the ready queue
99  *  and place it immediately at the rear of this chain.  Reset timeslice
100  *  and yield the processor functions both use this routine, therefore if
101  *  reset is true and this is the only thread on the queue then the
102  *  timeslice counter is reset.  The heir THREAD will be updated if the
103  *  running is also the currently the heir.
104  */
105 void _Scheduler_edf_Yield( void );
106
107 /**
108  *  This routine puts @a the_thread on to the priority-based ready queue.
109  *
110  *  @param[in] the_thread will be enqueued at the TAIL of its priority.
111  */
112 void _Scheduler_edf_Enqueue(
113   Thread_Control    *the_thread
114 );
115
116 /**
117  *  This routine puts @a the_thread to the head of the ready queue. 
118  *  For priority-based ready queues, the thread will be the first thread
119  *  at its priority level.
120  *
121  *  @param[in] the_thread will be enqueued at the HEAD of its priority.
122  */
123 void _Scheduler_edf_Enqueue_first(
124   Thread_Control    *the_thread
125 );
126
127 /**
128  *  This routine removes a specific thread from the scheduler's set
129  *  of ready threads.
130  *
131  *  @param[in] the_thread will be extracted from the ready set.
132  */
133 void _Scheduler_edf_Extract(
134   Thread_Control     *the_thread
135 );
136
137
138
139 #endif /*_SCHEDULER_EDF_H*/