RTEMS CPU Kit with SuperCore  4.10.99.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 
48 #define SCHEDULER_CBS_ENTRY_POINTS \
49  { \
50  _Scheduler_EDF_Initialize, /* initialize entry point */ \
51  _Scheduler_EDF_Schedule, /* schedule entry point */ \
52  _Scheduler_EDF_Yield, /* yield entry point */ \
53  _Scheduler_EDF_Block, /* block entry point */ \
54  _Scheduler_CBS_Unblock, /* unblock entry point */ \
55  _Scheduler_EDF_Change_priority, /* change priority entry point */ \
56  SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
57  _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \
58  _Scheduler_default_Node_destroy, /* node destroy entry point */ \
59  _Scheduler_EDF_Update_priority, /* update priority entry point */ \
60  _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
61  _Scheduler_CBS_Release_job, /* new period of task */ \
62  _Scheduler_default_Tick, /* tick entry point */ \
63  _Scheduler_default_Start_idle /* start idle entry point */ \
64  SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
65  }
66 
67 /* Return values for CBS server. */
68 #define SCHEDULER_CBS_OK 0
69 #define SCHEDULER_CBS_ERROR_GENERIC -16
70 #define SCHEDULER_CBS_ERROR_NO_MEMORY -17
71 #define SCHEDULER_CBS_ERROR_INVALID_PARAMETER -18
72 #define SCHEDULER_CBS_ERROR_UNAUTHORIZED -19
73 #define SCHEDULER_CBS_ERROR_UNIMPLEMENTED -20
74 #define SCHEDULER_CBS_ERROR_MISSING_COMPONENT -21
75 #define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22
76 #define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -23
77 #define SCHEDULER_CBS_ERROR_INTERNAL_ERROR -24
78 #define SCHEDULER_CBS_ERROR_NOT_FOUND -25
79 #define SCHEDULER_CBS_ERROR_FULL -26
80 #define SCHEDULER_CBS_ERROR_EMPTY -27
81 #define SCHEDULER_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOT_FOUND
82 
84 extern const uint32_t _Scheduler_CBS_Maximum_servers;
85 
87 typedef uint32_t Scheduler_CBS_Server_id;
88 
91  Scheduler_CBS_Server_id server_id
92 );
93 
97 typedef struct {
99  time_t deadline;
101  time_t budget;
103 
107 typedef struct {
118 
126 
130 typedef struct {
136 
137 
143 
158 Scheduler_Void_or_thread _Scheduler_CBS_Unblock(
159  const Scheduler_Control *scheduler,
160  Thread_Control *the_thread
161 );
162 
177  const Scheduler_Control *scheduler,
178  Thread_Control *the_thread,
179  uint32_t length
180 );
181 
189 int _Scheduler_CBS_Initialize(void);
190 
199  Scheduler_CBS_Server_id server_id,
200  rtems_id task_id
201 );
202 
211  Scheduler_CBS_Server_id server_id,
212  rtems_id task_id
213 );
214 
222 int _Scheduler_CBS_Cleanup (void);
223 
232  Scheduler_CBS_Parameters *params,
233  Scheduler_CBS_Budget_overrun budget_overrun_callback,
234  rtems_id *server_id
235 );
236 
247  Scheduler_CBS_Server_id server_id
248 );
249 
259  Scheduler_CBS_Server_id server_id,
260  time_t *approved_budget
261 );
262 
271  Scheduler_CBS_Server_id server_id,
272  time_t *remaining_budget
273 );
274 
287  Scheduler_CBS_Server_id server_id,
288  time_t *exec_time,
289  time_t *abs_time
290 );
291 
300  Scheduler_CBS_Server_id server_id,
302 );
303 
313  rtems_id task_id,
314  Scheduler_CBS_Server_id *server_id
315 );
316 
328  Scheduler_CBS_Server_id server_id,
329  Scheduler_CBS_Parameters *parameters
330 );
331 
338  Thread_Control *the_thread
339 );
340 
345  const Scheduler_Control *scheduler,
346  Thread_Control *the_thread
347 );
348 
349 #ifdef __cplusplus
350 }
351 #endif
352 
355 #endif
356 /* end of include file */
Constants and Structures Associated with the Red-Black Tree Handler.
Scheduler_CBS_Parameters parameters
Server paramenters.
Definition: schedulercbs.h:115
Scheduler control.
Definition: scheduler.h:191
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:80
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:96
int _Scheduler_CBS_Attach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Attach a task to an already existing server.
time_t budget
Budget (computation time) of the server.
Definition: schedulercbs.h:101
int _Scheduler_CBS_Get_server_id(rtems_id task_id, Scheduler_CBS_Server_id *server_id)
Get a thread server id.
int _Scheduler_CBS_Get_execution_time(Scheduler_CBS_Server_id server_id, time_t *exec_time, time_t *abs_time)
Get relative time info.
Scheduler_EDF_Node Base
EDF scheduler specific data of a task.
Definition: schedulercbs.h:132
rtems_id task_id
Task id.
Definition: schedulercbs.h:113
void _Scheduler_CBS_Release_job(const Scheduler_Control *scheduler, Thread_Control *the_thread, uint32_t length)
Called when a new job of task is released.
Data Related to the Manipulation of Threads for the EDF Scheduler.
const uint32_t _Scheduler_CBS_Maximum_servers
Maximum number of simultaneous servers.
void(* Scheduler_CBS_Budget_overrun)(Scheduler_CBS_Server_id server_id)
Callback function invoked when a budget overrun of a task occurs.
Definition: schedulercbs.h:90
Scheduler_CBS_Server * cbs_server
CBS server specific data of a task.
Definition: schedulercbs.h:134
time_t deadline
Relative deadline of the server.
Definition: schedulercbs.h:99
Constants and Structures Related with the Thread Control Block.
uint32_t Scheduler_CBS_Server_id
Server id.
Definition: schedulercbs.h:87
Signals API.
bool initialized
Indicates if this CBS server is initialized.
Definition: schedulercbs.h:124
int _Scheduler_CBS_Set_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *parameters)
Set parameters for CBS scheduling.
int _Scheduler_CBS_Initialize(void)
_Scheduler_CBS_Initialize
int _Scheduler_CBS_Get_approved_budget(Scheduler_CBS_Server_id server_id, time_t *approved_budget)
Retrieve the approved budget.
int _Scheduler_CBS_Get_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *params)
Retrieve CBS scheduling parameters.
Thread Priority Manipulation Routines.
Scheduler_CBS_Server _Scheduler_CBS_Server_list[]
List of servers.
This structure handles server parameters.
Definition: schedulercbs.h:97
This structure represents a time server.
Definition: schedulercbs.h:107
int _Scheduler_CBS_Destroy_server(Scheduler_CBS_Server_id server_id)
Detach all tasks from a server and destroy it.
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.
int _Scheduler_CBS_Cleanup(void)
Cleanup resources associated to the CBS Library.
int _Scheduler_CBS_Detach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Detach from the CBS Server.
Chain Handler API.
int _Scheduler_CBS_Get_remaining_budget(Scheduler_CBS_Server_id server_id, time_t *remaining_budget)
Retrieve remaining budget for the current server instance.
void _Scheduler_CBS_Budget_callout(Thread_Control *the_thread)
Invoked when a limited time quantum is exceeded.
This structure handles CBS specific data of a thread.
Definition: schedulercbs.h:130
Scheduler_Void_or_thread _Scheduler_CBS_Unblock(const Scheduler_Control *scheduler, Thread_Control *the_thread)
Unblocks a thread from the queue.
Constants and Structures Associated with the Scheduler.
This structure defines the Thread Control Block (TCB).
Definition: thread.h:574
Scheduler_CBS_Budget_overrun cbs_budget_overrun
Callback function invoked when a budget overrun occurs.
Definition: schedulercbs.h:117
void _Scheduler_CBS_Node_initialize(const Scheduler_Control *scheduler, Thread_Control *the_thread)
Initializes a CBS specific scheduler node of the_thread.