RTEMS 6.1-rc1
schedulercbs.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
13/*
14 * Copryight (c) 2011 Petr Benes.
15 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _RTEMS_SCORE_SCHEDULERCBS_H
40#define _RTEMS_SCORE_SCHEDULERCBS_H
41
42#include <rtems/score/chain.h>
45#include <rtems/score/rbtree.h>
47#include <rtems/rtems/signal.h>
48#include <rtems/rtems/timer.h>
49#include <rtems/score/thread.h>
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
66#define SCHEDULER_CBS_MAXIMUM_PRIORITY SCHEDULER_EDF_MAXIMUM_PRIORITY
67
74#define SCHEDULER_CBS_ENTRY_POINTS \
75 { \
76 _Scheduler_EDF_Initialize, /* initialize entry point */ \
77 _Scheduler_EDF_Schedule, /* schedule entry point */ \
78 _Scheduler_EDF_Yield, /* yield entry point */ \
79 _Scheduler_EDF_Block, /* block entry point */ \
80 _Scheduler_CBS_Unblock, /* unblock entry point */ \
81 _Scheduler_EDF_Update_priority, /* update priority entry point */ \
82 _Scheduler_EDF_Map_priority, /* map priority entry point */ \
83 _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \
84 SCHEDULER_DEFAULT_SMP_OPERATIONS \
85 _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \
86 _Scheduler_default_Node_destroy, /* node destroy entry point */ \
87 _Scheduler_CBS_Release_job, /* new period of task */ \
88 _Scheduler_CBS_Cancel_job, /* cancel period of task */ \
89 _Scheduler_default_Start_idle /* start idle entry point */ \
90 SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \
91 }
92
93/* Return values for CBS server. */
94#define SCHEDULER_CBS_OK 0
95#define SCHEDULER_CBS_ERROR_GENERIC -16
96#define SCHEDULER_CBS_ERROR_NO_MEMORY -17
97#define SCHEDULER_CBS_ERROR_INVALID_PARAMETER -18
98#define SCHEDULER_CBS_ERROR_UNAUTHORIZED -19
99#define SCHEDULER_CBS_ERROR_UNIMPLEMENTED -20
100#define SCHEDULER_CBS_ERROR_MISSING_COMPONENT -21
101#define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22
102#define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -23
103#define SCHEDULER_CBS_ERROR_INTERNAL_ERROR -24
104#define SCHEDULER_CBS_ERROR_NOT_FOUND -25
105#define SCHEDULER_CBS_ERROR_FULL -26
106#define SCHEDULER_CBS_ERROR_EMPTY -27
107#define SCHEDULER_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOT_FOUND
108
110extern const uint32_t _Scheduler_CBS_Maximum_servers;
111
113typedef uint32_t Scheduler_CBS_Server_id;
114
118);
119
123typedef struct {
125 time_t deadline;
127 time_t budget;
129
133typedef struct {
144
152
156typedef struct {
161
162 Priority_Node *deadline_node;
164
165
171
180 const Scheduler_Control *scheduler,
181 Thread_Control *the_thread,
182 Scheduler_Node *node
183);
184
195 const Scheduler_Control *scheduler,
196 Thread_Control *the_thread,
197 Priority_Node *priority_node,
198 uint64_t deadline,
199 Thread_queue_Context *queue_context
200);
201
211 const Scheduler_Control *scheduler,
212 Thread_Control *the_thread,
213 Priority_Node *priority_node,
214 Thread_queue_Context *queue_context
215);
216
225
241 Scheduler_CBS_Server_id server_id,
242 rtems_id task_id
243);
244
260 Scheduler_CBS_Server_id server_id,
261 rtems_id task_id
262);
263
271int _Scheduler_CBS_Cleanup (void);
272
290 Scheduler_CBS_Budget_overrun budget_overrun_callback,
291 rtems_id *server_id
292);
293
307);
308
323 Scheduler_CBS_Server_id server_id,
324 time_t *approved_budget
325);
326
340 Scheduler_CBS_Server_id server_id,
341 time_t *remaining_budget
342);
343
358 Scheduler_CBS_Server_id server_id,
359 time_t *exec_time,
360 time_t *abs_time
361);
362
376 Scheduler_CBS_Server_id server_id,
378);
379
392 rtems_id task_id,
393 Scheduler_CBS_Server_id *server_id
394);
395
410 Scheduler_CBS_Server_id server_id,
411 Scheduler_CBS_Parameters *parameters
412);
413
418
428 const Scheduler_Control *scheduler,
429 Scheduler_Node *node,
430 Thread_Control *the_thread,
431 Priority_Control priority
432);
433
434#ifdef __cplusplus
435}
436#endif
437
440#endif
441/* end of include file */
This header file provides the Timer Manager API.
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:91
int _Scheduler_CBS_Get_server_id(rtems_id task_id, Scheduler_CBS_Server_id *server_id)
Gets a thread server id.
Definition: schedulercbsgetserverid.c:46
Scheduler_CBS_Server _Scheduler_CBS_Server_list[]
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:44
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:45
int _Scheduler_CBS_Cleanup(void)
Cleans up resources associated to the CBS Library.
Definition: schedulercbscleanup.c:44
void(* Scheduler_CBS_Budget_overrun)(Scheduler_CBS_Server_id server_id)
Definition: schedulercbs.h:116
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:45
int _Scheduler_CBS_Get_approved_budget(Scheduler_CBS_Server_id server_id, time_t *approved_budget)
Retrieves the approved budget.
Definition: schedulercbsgetapprovedbudget.c:46
int _Scheduler_CBS_Detach_thread(Scheduler_CBS_Server_id server_id, rtems_id task_id)
Detaches from the CBS Server.
Definition: schedulercbsdetachthread.c:45
int _Scheduler_CBS_Destroy_server(Scheduler_CBS_Server_id server_id)
Detaches all tasks from a server and destroys it.
Definition: schedulercbsdestroyserver.c:44
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:74
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:45
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:44
const Thread_CPU_budget_operations _Scheduler_CBS_Budget
These are the CBS CPU budget operations.
Definition: schedulercbs.c:103
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:45
const uint32_t _Scheduler_CBS_Maximum_servers
int _Scheduler_CBS_Initialize(void)
_Scheduler_CBS_Initialize
Definition: schedulercbs.c:109
void _Scheduler_CBS_Unblock(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Unblocks a thread.
Definition: schedulercbsunblock.c:48
int _Scheduler_CBS_Get_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *params)
Retrieves CBS scheduling parameters.
Definition: schedulercbsgetparameters.c:46
uint32_t Scheduler_CBS_Server_id
Definition: schedulercbs.h:113
int _Scheduler_CBS_Set_parameters(Scheduler_CBS_Server_id server_id, Scheduler_CBS_Parameters *parameters)
Sets parameters for CBS scheduling.
Definition: schedulercbssetparameters.c:45
This header file defines the parts of the Signal Manager API.
This header file provides interfaces of the Priority Handler which are used by the implementation and...
This header file provides interfaces of the Red-Black Tree Handler which are used by the implementati...
This header file provides interfaces of the EDF Scheduler which are used by the implementation and th...
This header file provides interfaces of the Chain Handler which are used by the implementation and th...
This header file provides interfaces of the Scheduler Handler which are used by the implementation an...
This header file provides interfaces of the Thread Handler which are used by the implementation and t...
The priority node to build up a priority aggregation.
Definition: priority.h:112
Definition: schedulercbs.h:156
Scheduler_CBS_Server * cbs_server
Definition: schedulercbs.h:160
Scheduler_EDF_Node Base
Definition: schedulercbs.h:158
Definition: schedulercbs.h:123
time_t deadline
Definition: schedulercbs.h:125
time_t budget
Definition: schedulercbs.h:127
Definition: schedulercbs.h:133
Scheduler_CBS_Parameters parameters
Definition: schedulercbs.h:141
rtems_id task_id
Definition: schedulercbs.h:139
bool initialized
Indicates if this CBS server is initialized.
Definition: schedulercbs.h:150
Scheduler_CBS_Budget_overrun cbs_budget_overrun
Definition: schedulercbs.h:143
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:107
Scheduler node for per-thread data.
Definition: schedulernode.h:94
This structure contains operations which manage the CPU budget of a thread.
Definition: thread.h:165
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Scheduler control.
Definition: scheduler.h:335
Definition: thread.h:812