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