RTEMS  5.1
schedulercbs.h
Go to the documentation of this file.
1 
12 /*
13  * Copryight (c) 2011 Petr Benes.
14  * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #ifndef _RTEMS_SCORE_SCHEDULERCBS_H
22 #define _RTEMS_SCORE_SCHEDULERCBS_H
23 
24 #include <rtems/score/chain.h>
25 #include <rtems/score/priority.h>
26 #include <rtems/score/scheduler.h>
27 #include <rtems/score/rbtree.h>
29 #include <rtems/rtems/signal.h>
30 #include <rtems/rtems/timer.h>
31 #include <rtems/score/thread.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
47 #define SCHEDULER_CBS_MAXIMUM_PRIORITY SCHEDULER_EDF_MAXIMUM_PRIORITY
48 
55 #define SCHEDULER_CBS_ENTRY_POINTS \
56  { \
57  _Scheduler_EDF_Initialize, /* initialize entry point */ \
58  _Scheduler_EDF_Schedule, /* schedule entry point */ \
59  _Scheduler_EDF_Yield, /* yield entry point */ \
60  _Scheduler_EDF_Block, /* block entry point */ \
61  _Scheduler_CBS_Unblock, /* unblock entry point */ \
62  _Scheduler_EDF_Update_priority, /* update priority entry point */ \
63  _Scheduler_EDF_Map_priority, /* map priority entry point */ \
64  _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \
65  SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
66  _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \
67  _Scheduler_default_Node_destroy, /* node destroy entry point */ \
68  _Scheduler_CBS_Release_job, /* new period of task */ \
69  _Scheduler_CBS_Cancel_job, /* cancel period of task */ \
70  _Scheduler_default_Tick, /* tick entry point */ \
71  _Scheduler_default_Start_idle /* start idle entry point */ \
72  SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
73  }
74 
75 /* Return values for CBS server. */
76 #define SCHEDULER_CBS_OK 0
77 #define SCHEDULER_CBS_ERROR_GENERIC -16
78 #define SCHEDULER_CBS_ERROR_NO_MEMORY -17
79 #define SCHEDULER_CBS_ERROR_INVALID_PARAMETER -18
80 #define SCHEDULER_CBS_ERROR_UNAUTHORIZED -19
81 #define SCHEDULER_CBS_ERROR_UNIMPLEMENTED -20
82 #define SCHEDULER_CBS_ERROR_MISSING_COMPONENT -21
83 #define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22
84 #define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -23
85 #define SCHEDULER_CBS_ERROR_INTERNAL_ERROR -24
86 #define SCHEDULER_CBS_ERROR_NOT_FOUND -25
87 #define SCHEDULER_CBS_ERROR_FULL -26
88 #define SCHEDULER_CBS_ERROR_EMPTY -27
89 #define SCHEDULER_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOT_FOUND
90 
92 extern const uint32_t _Scheduler_CBS_Maximum_servers;
93 
95 typedef uint32_t Scheduler_CBS_Server_id;
96 
99  Scheduler_CBS_Server_id server_id
100 );
101 
105 typedef struct {
107  time_t deadline;
109  time_t budget;
111 
115 typedef struct {
126 
134 
138 typedef struct {
143 
144  Priority_Node *deadline_node;
146 
147 
153 
162  const Scheduler_Control *scheduler,
163  Thread_Control *the_thread,
164  Scheduler_Node *node
165 );
166 
177  const Scheduler_Control *scheduler,
178  Thread_Control *the_thread,
179  Priority_Node *priority_node,
180  uint64_t deadline,
181  Thread_queue_Context *queue_context
182 );
183 
193  const Scheduler_Control *scheduler,
194  Thread_Control *the_thread,
195  Priority_Node *priority_node,
196  Thread_queue_Context *queue_context
197 );
198 
206 int _Scheduler_CBS_Initialize(void);
207 
223  Scheduler_CBS_Server_id server_id,
224  rtems_id task_id
225 );
226 
242  Scheduler_CBS_Server_id server_id,
243  rtems_id task_id
244 );
245 
253 int _Scheduler_CBS_Cleanup (void);
254 
271  Scheduler_CBS_Parameters *params,
272  Scheduler_CBS_Budget_overrun budget_overrun_callback,
273  rtems_id *server_id
274 );
275 
288  Scheduler_CBS_Server_id server_id
289 );
290 
305  Scheduler_CBS_Server_id server_id,
306  time_t *approved_budget
307 );
308 
322  Scheduler_CBS_Server_id server_id,
323  time_t *remaining_budget
324 );
325 
340  Scheduler_CBS_Server_id server_id,
341  time_t *exec_time,
342  time_t *abs_time
343 );
344 
358  Scheduler_CBS_Server_id server_id,
360 );
361 
374  rtems_id task_id,
375  Scheduler_CBS_Server_id *server_id
376 );
377 
392  Scheduler_CBS_Server_id server_id,
393  Scheduler_CBS_Parameters *parameters
394 );
395 
404  Thread_Control *the_thread
405 );
406 
416  const Scheduler_Control *scheduler,
417  Scheduler_Node *node,
418  Thread_Control *the_thread,
419  Priority_Control priority
420 );
421 
422 #ifdef __cplusplus
423 }
424 #endif
425 
428 #endif
429 /* end of include file */
int _Scheduler_CBS_Create_server(Scheduler_CBS_Parameters *params, Scheduler_CBS_Budget_overrun budget_overrun_callback, rtems_id *server_id)
Creates a new server with specified parameters.
Definition: schedulercbscreateserver.c:24
int _Scheduler_CBS_Detach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Detaches from the CBS Server.
Definition: schedulercbsdetachthread.c:25
void _Scheduler_CBS_Cancel_job(const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context)
Cancels a job.
Definition: schedulercbsreleasejob.c:54
uint32_t Scheduler_CBS_Server_id
Definition: schedulercbs.h:95
Scheduler_CBS_Parameters parameters
Definition: schedulercbs.h:123
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
const uint32_t _Scheduler_CBS_Maximum_servers
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:90
Thread queue context for the thread queue methods.
Definition: threadq.h:198
The priority node to build up a priority aggregation.
Definition: priority.h:98
time_t budget
Definition: schedulercbs.h:109
int _Scheduler_CBS_Get_remaining_budget(Scheduler_CBS_Server_id server_id, time_t *remaining_budget)
Retrieves remaining budget for the current server instance.
Definition: schedulercbsgetremainingbudget.c:24
Scheduler_EDF_Node Base
Definition: schedulercbs.h:140
rtems_id task_id
Definition: schedulercbs.h:121
Data Related to the Manipulation of Threads for the EDF Scheduler.
Scheduler_CBS_Server * cbs_server
Definition: schedulercbs.h:142
int _Scheduler_CBS_Set_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *parameters)
Sets parameters for CBS scheduling.
Definition: schedulercbssetparameters.c:25
time_t deadline
Definition: schedulercbs.h:107
int _Scheduler_CBS_Get_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *params)
Retrieves CBS scheduling parameters.
Definition: schedulercbsgetparameters.c:26
Signals API.
Definition: thread.h:732
bool initialized
Indicates if this CBS server is initialized.
Definition: schedulercbs.h:132
Scheduler_CBS_Server _Scheduler_CBS_Server_list[]
int _Scheduler_CBS_Get_approved_budget(Scheduler_CBS_Server_id server_id, time_t *approved_budget)
Retrieves the approved budget.
Definition: schedulercbsgetapprovedbudget.c:25
int _Scheduler_CBS_Get_execution_time(Scheduler_CBS_Server_id server_id, time_t *exec_time, time_t *abs_time)
Gets relative time info.
Definition: schedulercbsgetexecutiontime.c:25
Constants and Structures Associated with the Red-Black Tree Handler.
void _Scheduler_CBS_Unblock(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Unblocks a thread.
Definition: schedulercbsunblock.c:28
Priority Handler API.
void _Scheduler_CBS_Budget_callout(Thread_Control *the_thread)
Invoked when a limited time quantum is exceeded.
Definition: schedulercbs.c:24
Definition: schedulercbs.h:105
void(* Scheduler_CBS_Budget_overrun)(Scheduler_CBS_Server_id server_id)
Definition: schedulercbs.h:98
Definition: schedulercbs.h:115
int _Scheduler_CBS_Cleanup(void)
Cleans up resources associated to the CBS Library.
Definition: schedulercbscleanup.c:24
Chain Handler API.
int _Scheduler_CBS_Get_server_id(rtems_id task_id, Scheduler_CBS_Server_id *server_id)
Gets a thread server id.
Definition: schedulercbsgetserverid.c:25
Classic Timer Manager API.
Scheduler control.
Definition: scheduler.h:269
Scheduler node for per-thread data.
Definition: schedulernode.h:79
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
int _Scheduler_CBS_Initialize(void)
_Scheduler_CBS_Initialize
Definition: schedulercbs.c:54
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
void _Scheduler_CBS_Release_job(const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, uint64_t deadline, Thread_queue_Context *queue_context)
Releases a job.
Definition: schedulercbsreleasejob.c:24
Definition: schedulercbs.h:138
int _Scheduler_CBS_Destroy_server(Scheduler_CBS_Server_id server_id)
Detaches all tasks from a server and destroys it.
Definition: schedulercbsdestroyserver.c:25
Constants and Structures Associated with the Scheduler.
Constants and Structures Related with the Thread Control Block.
int _Scheduler_CBS_Attach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Attaches a task to an already existing server.
Definition: schedulercbsattachthread.c:24
Scheduler_CBS_Budget_overrun cbs_budget_overrun
Definition: schedulercbs.h:125