RTEMS 6.1-rc5
Loading...
Searching...
No Matches
qreslib.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
15/*
16 * Copyright (C) 2011 Petr Benes.
17 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef CONFIGURE_SCHEDULER_CBS
42 #error "qreslib.h available only with CONFIGURE_SCHEDULER_CBS"
43#endif
44
45#ifndef _QRESLIB_H
46#define _QRESLIB_H
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#include <stdint.h>
54
56typedef int qos_rv;
57
58/* Return codes. */
59#define QOS_OK SCHEDULER_CBS_OK
60#define QOS_E_GENERIC SCHEDULER_CBS_ERROR_GENERIC
61#define QOS_E_NO_MEMORY SCHEDULER_CBS_ERROR_NO_MEMORY
62#define QOS_E_INVALID_PARAM SCHEDULER_CBS_ERROR_INVALID_PARAMETER
63#define QOS_E_UNAUTHORIZED SCHEDULER_CBS_ERROR_UNAUTHORIZED
64#define QOS_E_UNIMPLEMENTED SCHEDULER_CBS_ERROR_UNIMPLEMENTED
65#define QOS_E_MISSING_COMPONENT SCHEDULER_CBS_ERROR_MISSING_COMPONENT
66#define QOS_E_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE
67#define QOS_E_SYSTEM_OVERLOAD SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD
68#define QOS_E_INTERNAL_ERROR SCHEDULER_CBS_ERROR_INTERNAL_ERROR
69#define QOS_E_NOT_FOUND SCHEDULER_CBS_ERROR_NOT_FOUND
70#define QOS_E_FULL SCHEDULER_CBS_ERROR_FULL
71#define QOS_E_EMPTY SCHEDULER_CBS_ERROR_EMPTY
72#define QOS_E_NOSERVER SCHEDULER_CBS_ERROR_NOSERVER
73
76
79
81typedef time_t qres_time_t;
82
84typedef time_t qres_atime_t;
85
87typedef struct {
93
101static inline qos_rv qres_init ( void )
102{
104}
105
113static inline qos_rv qres_cleanup ( void )
114{
115 return _Scheduler_CBS_Cleanup();
116}
117
125static inline qos_rv qres_create_server (
126 qres_params_t *params,
127 qres_sid_t *server_id
128)
129{
131 (Scheduler_CBS_Parameters *) params,
132 NULL,
133 server_id
134 );
135}
136
144static inline qos_rv qres_attach_thread (
145 qres_sid_t server_id,
146 pid_t pid,
147 tid_t task_id
148)
149{
150 return _Scheduler_CBS_Attach_thread( server_id, task_id );
151}
152
160static inline qos_rv qres_detach_thread (
161 qres_sid_t server_id,
162 pid_t pid,
163 tid_t task_id
164)
165{
166 return _Scheduler_CBS_Detach_thread( server_id, task_id );
167}
168
176static inline qos_rv qres_destroy_server (
177 qres_sid_t server_id
178)
179{
180 return _Scheduler_CBS_Destroy_server( server_id );
181}
182
191static inline qos_rv qres_get_sid (
192 pid_t pid,
193 tid_t task_id,
194 qres_sid_t *server_id
195)
196{
197 return _Scheduler_CBS_Get_server_id( task_id, server_id );
198}
199
207static inline qos_rv qres_get_params (
208 qres_sid_t server_id,
209 qres_params_t *params
210)
211{
213 server_id,
214 (Scheduler_CBS_Parameters *) params
215 );
216}
217
225static inline qos_rv qres_set_params (
226 qres_sid_t server_id,
227 qres_params_t *params
228)
229{
231 server_id,
232 (Scheduler_CBS_Parameters *) params
233 );
234}
235
243static inline qos_rv qres_get_exec_time (
244 qres_sid_t server_id,
245 qres_time_t *exec_time,
246 qres_atime_t *abs_time
247)
248{
249 return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time );
250}
251
259static inline qos_rv qres_get_curr_budget (
260 qres_sid_t server_id,
261 qres_time_t *current_budget
262)
263{
264 return _Scheduler_CBS_Get_remaining_budget( server_id, current_budget );
265}
266
275static inline qos_rv qres_get_appr_budget (
276 qres_sid_t server_id,
277 qres_time_t *appr_budget
278)
279{
280 return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget );
281}
282
283#ifdef __cplusplus
284}
285#endif
286
287#endif
288/* end of include file */
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
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
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
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
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
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
int _Scheduler_CBS_Initialize(void)
_Scheduler_CBS_Initialize
Definition: schedulercbs.c:109
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
Scheduler_CBS_Server_id qres_sid_t
Definition: qreslib.h:75
int qos_rv
Definition: qreslib.h:56
time_t qres_time_t
Definition: qreslib.h:81
time_t qres_atime_t
Definition: qreslib.h:84
rtems_id tid_t
Definition: qreslib.h:78
This header file provides interfaces of the Constant Bandwidth Server (CBS) Scheduler which are used ...
Definition: schedulercbs.h:123
Definition: qreslib.h:87
qres_time_t Q
Definition: qreslib.h:91
qres_time_t P
Definition: qreslib.h:89