RTEMS  5.0.0
schedulercbs.h
Go to the documentation of this file.
1 
10 /*
11  * Copryight (c) 2011 Petr Benes.
12  * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_SCHEDULERCBS_H
20 #define _RTEMS_SCORE_SCHEDULERCBS_H
21 
22 #include <rtems/score/chain.h>
23 #include <rtems/score/priority.h>
24 #include <rtems/score/scheduler.h>
25 #include <rtems/score/rbtree.h>
27 #include <rtems/rtems/signal.h>
28 #include <rtems/rtems/timer.h>
29 #include <rtems/score/thread.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
42 #define SCHEDULER_CBS_MAXIMUM_PRIORITY SCHEDULER_EDF_MAXIMUM_PRIORITY
43 
50 #define SCHEDULER_CBS_ENTRY_POINTS \
51  { \
52  _Scheduler_EDF_Initialize, /* initialize entry point */ \
53  _Scheduler_EDF_Schedule, /* schedule entry point */ \
54  _Scheduler_EDF_Yield, /* yield entry point */ \
55  _Scheduler_EDF_Block, /* block entry point */ \
56  _Scheduler_CBS_Unblock, /* unblock entry point */ \
57  _Scheduler_EDF_Update_priority, /* update priority entry point */ \
58  _Scheduler_EDF_Map_priority, /* map priority entry point */ \
59  _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \
60  SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
61  _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \
62  _Scheduler_default_Node_destroy, /* node destroy entry point */ \
63  _Scheduler_CBS_Release_job, /* new period of task */ \
64  _Scheduler_CBS_Cancel_job, /* cancel period of task */ \
65  _Scheduler_default_Tick, /* tick entry point */ \
66  _Scheduler_default_Start_idle /* start idle entry point */ \
67  SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
68  }
69 
70 /* Return values for CBS server. */
71 #define SCHEDULER_CBS_OK 0
72 #define SCHEDULER_CBS_ERROR_GENERIC -16
73 #define SCHEDULER_CBS_ERROR_NO_MEMORY -17
74 #define SCHEDULER_CBS_ERROR_INVALID_PARAMETER -18
75 #define SCHEDULER_CBS_ERROR_UNAUTHORIZED -19
76 #define SCHEDULER_CBS_ERROR_UNIMPLEMENTED -20
77 #define SCHEDULER_CBS_ERROR_MISSING_COMPONENT -21
78 #define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22
79 #define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -23
80 #define SCHEDULER_CBS_ERROR_INTERNAL_ERROR -24
81 #define SCHEDULER_CBS_ERROR_NOT_FOUND -25
82 #define SCHEDULER_CBS_ERROR_FULL -26
83 #define SCHEDULER_CBS_ERROR_EMPTY -27
84 #define SCHEDULER_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOT_FOUND
85 
87 extern const uint32_t _Scheduler_CBS_Maximum_servers;
88 
90 typedef uint32_t Scheduler_CBS_Server_id;
91 
94  Scheduler_CBS_Server_id server_id
95 );
96 
100 typedef struct {
102  time_t deadline;
104  time_t budget;
106 
110 typedef struct {
121 
129 
133 typedef struct {
138 
139  Priority_Node *deadline_node;
141 
142 
148 
149 void _Scheduler_CBS_Unblock(
150  const Scheduler_Control *scheduler,
151  Thread_Control *the_thread,
152  Scheduler_Node *node
153 );
154 
155 void _Scheduler_CBS_Release_job(
156  const Scheduler_Control *scheduler,
157  Thread_Control *the_thread,
158  Priority_Node *priority_node,
159  uint64_t deadline,
160  Thread_queue_Context *queue_context
161 );
162 
163 void _Scheduler_CBS_Cancel_job(
164  const Scheduler_Control *scheduler,
165  Thread_Control *the_thread,
166  Priority_Node *priority_node,
167  Thread_queue_Context *queue_context
168 );
169 
177 int _Scheduler_CBS_Initialize(void);
178 
187  Scheduler_CBS_Server_id server_id,
188  rtems_id task_id
189 );
190 
199  Scheduler_CBS_Server_id server_id,
200  rtems_id task_id
201 );
202 
210 int _Scheduler_CBS_Cleanup (void);
211 
220  Scheduler_CBS_Parameters *params,
221  Scheduler_CBS_Budget_overrun budget_overrun_callback,
222  rtems_id *server_id
223 );
224 
235  Scheduler_CBS_Server_id server_id
236 );
237 
247  Scheduler_CBS_Server_id server_id,
248  time_t *approved_budget
249 );
250 
259  Scheduler_CBS_Server_id server_id,
260  time_t *remaining_budget
261 );
262 
275  Scheduler_CBS_Server_id server_id,
276  time_t *exec_time,
277  time_t *abs_time
278 );
279 
288  Scheduler_CBS_Server_id server_id,
290 );
291 
301  rtems_id task_id,
302  Scheduler_CBS_Server_id *server_id
303 );
304 
316  Scheduler_CBS_Server_id server_id,
317  Scheduler_CBS_Parameters *parameters
318 );
319 
326  Thread_Control *the_thread
327 );
328 
333  const Scheduler_Control *scheduler,
334  Scheduler_Node *node,
335  Thread_Control *the_thread,
336  Priority_Control priority
337 );
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
345 #endif
346 /* end of include file */
Scheduler_CBS_Parameters parameters
Definition: schedulercbs.h:118
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:85
int _Scheduler_CBS_Attach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Attach a task to an already existing server.
Definition: schedulercbsattachthread.c:24
Thread queue context for the thread queue methods.
Definition: threadq.h:193
The priority node to build up a priority aggregation.
Definition: priority.h:94
time_t budget
Definition: schedulercbs.h:104
int _Scheduler_CBS_Get_server_id(rtems_id task_id, Scheduler_CBS_Server_id *server_id)
Get a thread server id.
Definition: schedulercbsgetserverid.c:25
int _Scheduler_CBS_Get_execution_time(Scheduler_CBS_Server_id server_id, time_t *exec_time, time_t *abs_time)
Get relative time info.
Definition: schedulercbsgetexecutiontime.c:25
Scheduler_EDF_Node Base
Definition: schedulercbs.h:135
rtems_id task_id
Definition: schedulercbs.h:116
Data Related to the Manipulation of Threads for the EDF Scheduler.
void _Scheduler_CBS_Node_initialize(const Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority)
Initializes a CBS specific scheduler node of the_thread.
Definition: schedulercbsnodeinit.c:23
const uint32_t _Scheduler_CBS_Maximum_servers
void(* Scheduler_CBS_Budget_overrun)(Scheduler_CBS_Server_id server_id)
Definition: schedulercbs.h:93
Scheduler_CBS_Server * cbs_server
Definition: schedulercbs.h:137
time_t deadline
Definition: schedulercbs.h:102
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
uint32_t Scheduler_CBS_Server_id
Definition: schedulercbs.h:90
Signals API.
Definition: thread.h:728
bool initialized
Indicates if this CBS server is initialized.
Definition: schedulercbs.h:127
int _Scheduler_CBS_Set_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *parameters)
Set parameters for CBS scheduling.
Definition: schedulercbssetparameters.c:25
int _Scheduler_CBS_Initialize(void)
_Scheduler_CBS_Initialize
Definition: schedulercbs.c:53
int _Scheduler_CBS_Get_approved_budget(Scheduler_CBS_Server_id server_id, time_t *approved_budget)
Retrieve the approved budget.
Definition: schedulercbsgetapprovedbudget.c:25
int _Scheduler_CBS_Get_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *params)
Retrieve CBS scheduling parameters.
Definition: schedulercbsgetparameters.c:25
Constants and Structures Associated with the Red-Black Tree Handler.
Priority Handler API.
Scheduler_CBS_Server _Scheduler_CBS_Server_list[]
Definition: schedulercbs.h:100
Definition: schedulercbs.h:110
int _Scheduler_CBS_Destroy_server(Scheduler_CBS_Server_id server_id)
Detach all tasks from a server and destroy it.
Definition: schedulercbsdestroyserver.c:25
int _Scheduler_CBS_Create_server(Scheduler_CBS_Parameters *params, Scheduler_CBS_Budget_overrun budget_overrun_callback, rtems_id *server_id)
Create a new server with specified parameters.
Definition: schedulercbscreateserver.c:24
int _Scheduler_CBS_Cleanup(void)
Cleanup resources associated to the CBS Library.
Definition: schedulercbscleanup.c:24
int _Scheduler_CBS_Detach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Detach from the CBS Server.
Definition: schedulercbsdetachthread.c:25
Chain Handler API.
Classic Timer Manager API.
Scheduler control.
Definition: scheduler.h:266
Scheduler node for per-thread data.
Definition: schedulernode.h:65
int _Scheduler_CBS_Get_remaining_budget(Scheduler_CBS_Server_id server_id, time_t *remaining_budget)
Retrieve remaining budget for the current server instance.
Definition: schedulercbsgetremainingbudget.c:24
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
void _Scheduler_CBS_Budget_callout(Thread_Control *the_thread)
Invoked when a limited time quantum is exceeded.
Definition: schedulercbs.c:23
Definition: schedulercbs.h:133
Constants and Structures Associated with the Scheduler.
Constants and Structures Related with the Thread Control Block.
Scheduler_CBS_Budget_overrun cbs_budget_overrun
Definition: schedulercbs.h:120