source: rtems/cpukit/libqos/qreslib.h @ 9ab091e

4.11
Last change on this file since 9ab091e was 9ab091e, checked in by Mathew Kallada <matkallada@…>, on Dec 28, 2012 at 4:35:32 PM

Header File Doxygen Enhancement Task #2

  • Property mode set to 100644
File size: 5.7 KB
Line 
1/**
2 * @file qreslib.h
3 *
4 * @brief Constants and Structures Associated
5 * with the QoS RES library in RTEMS
6 *
7 * This include file contains all the constants and structures
8 * associated with the QoS RES library in RTEMS.
9 *
10 * @note The library is available only together with CBS scheduler.
11 */
12
13/*
14 *  Copyright (C) 2011 Petr Benes.
15 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.com/license/LICENSE.
20 */
21
22#ifndef CONFIGURE_SCHEDULER_CBS
23  #error "qreslib.h available only with CONFIGURE_SCHEDULER_CBS"
24#endif
25
26#ifndef _QRESLIB_H
27#define _QRESLIB_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <stdint.h>
34#include <rtems/score/schedulercbs.h>
35
36/** Return values. */
37typedef int qos_rv;
38
39/* Return codes. */
40#define QOS_OK                   SCHEDULER_CBS_OK
41#define QOS_E_GENERIC            SCHEDULER_CBS_ERROR_GENERIC
42#define QOS_E_NO_MEMORY          SCHEDULER_CBS_ERROR_NO_MEMORY
43#define QOS_E_INVALID_PARAM      SCHEDULER_CBS_ERROR_INVALID_PARAMETER
44#define QOS_E_UNAUTHORIZED       SCHEDULER_CBS_ERROR_UNAUTHORIZED
45#define QOS_E_UNIMPLEMENTED      SCHEDULER_CBS_ERROR_UNIMPLEMENTED
46#define QOS_E_MISSING_COMPONENT  SCHEDULER_CBS_ERROR_MISSING_COMPONENT
47#define QOS_E_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE
48#define QOS_E_SYSTEM_OVERLOAD    SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD
49#define QOS_E_INTERNAL_ERROR     SCHEDULER_CBS_ERROR_INTERNAL_ERROR
50#define QOS_E_NOT_FOUND          SCHEDULER_CBS_ERROR_NOT_FOUND
51#define QOS_E_FULL               SCHEDULER_CBS_ERROR_FULL
52#define QOS_E_EMPTY              SCHEDULER_CBS_ERROR_EMPTY
53#define QOS_E_NOSERVER           SCHEDULER_CBS_ERROR_NOSERVER
54
55/** Server id. */
56typedef Scheduler_CBS_Server_id qres_sid_t;
57
58/** Task id. */
59typedef rtems_id tid_t;
60
61/** Time value. */
62typedef time_t qres_time_t;
63
64/** Absolute time value */
65typedef time_t qres_atime_t;
66
67/** Server parameters. */
68typedef struct {
69  /** Relative deadline of the server. */
70  uint32_t P;
71  /** Budget (computation time) of the server. */
72  uint32_t Q;
73} qres_params_t;
74
75/**
76 *  @brief qres init
77 *
78 *  Initializes the QoS RES library.
79 *
80 *  @return status code.
81 */
82RTEMS_INLINE_ROUTINE qos_rv qres_init ( void )
83{
84  return _Scheduler_CBS_Initialize();
85}
86
87/**
88 *  @brief qres cleanup
89 *
90 *  Cleanup resources associated to the QoS RES Library.
91 *
92 *  @return status code.
93 */
94RTEMS_INLINE_ROUTINE qos_rv qres_cleanup ( void )
95{
96  return _Scheduler_CBS_Cleanup();
97}
98
99/**
100 *  @brief qres create server
101 *
102 *  Create a new server with specified parameters.
103 *
104 *  @return status code.
105 */
106RTEMS_INLINE_ROUTINE qos_rv qres_create_server (
107  qres_params_t *params,
108  qres_sid_t    *server_id
109)
110{
111  return _Scheduler_CBS_Create_server(
112             (Scheduler_CBS_Parameters *) params,
113             NULL,
114             server_id
115         );
116}
117
118/**
119 *  @brief qres attach thread
120 *
121 *  Attach a task to an already existing server.
122 *
123 *  @return status code.
124 */
125RTEMS_INLINE_ROUTINE qos_rv qres_attach_thread (
126  qres_sid_t server_id,
127  pid_t      pid,
128  tid_t      task_id
129)
130{
131  return _Scheduler_CBS_Attach_thread( server_id, task_id );
132}
133
134/**
135 *  @brief qres detach thread
136 *
137 *  Detach from the QoS Server.
138 *
139 *  @return status code.
140 */
141RTEMS_INLINE_ROUTINE qos_rv qres_detach_thread (
142  qres_sid_t server_id,
143  pid_t      pid,
144  tid_t      task_id
145)
146{
147  return _Scheduler_CBS_Detach_thread( server_id, task_id );
148}
149
150/**
151 *  @brief qres destroy server
152 *
153 *  Detach all tasks from a server and destroy it.
154 *
155 *  @return status code.
156 */
157RTEMS_INLINE_ROUTINE qos_rv qres_destroy_server (
158  qres_sid_t server_id
159)
160{
161  return _Scheduler_CBS_Destroy_server( server_id );
162}
163
164/**
165 *  @brief qres get server id
166 *
167 *  Get a thread server id, or QOS_E_NOT_FOUND if it is not
168 *  attached to any server.
169 *
170 *  @return status code.
171 */
172RTEMS_INLINE_ROUTINE qos_rv qres_get_sid (
173  pid_t       pid,
174  tid_t       task_id,
175  qres_sid_t *server_id
176)
177{
178  return _Scheduler_CBS_Get_server_id( task_id, server_id );
179}
180
181/**
182 *  @brief qres get params
183 *
184 *  Retrieve QoS scheduling parameters.
185 *
186 *  @return status code.
187 */
188RTEMS_INLINE_ROUTINE qos_rv qres_get_params (
189  qres_sid_t     server_id,
190  qres_params_t *params
191)
192{
193  return _Scheduler_CBS_Get_parameters(
194             server_id,
195             (Scheduler_CBS_Parameters *) params
196         );
197}
198
199/**
200 *  @brief qres set params
201 *
202 *  Change QoS scheduling parameters.
203 *
204 *  @return status code.
205 */
206RTEMS_INLINE_ROUTINE qos_rv qres_set_params (
207  qres_sid_t     server_id,
208  qres_params_t *params
209)
210{
211  return _Scheduler_CBS_Set_parameters(
212             server_id,
213             (Scheduler_CBS_Parameters *) params
214         );
215}
216
217/**
218 *  @brief qres get execution time
219 *
220 *  Retrieve time info relative to the current server.
221 *
222 *  @return status code.
223 */
224RTEMS_INLINE_ROUTINE qos_rv qres_get_exec_time (
225  qres_sid_t    server_id,
226  qres_time_t  *exec_time,
227  qres_atime_t *abs_time
228)
229{
230  return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time );
231}
232
233/**
234 *  @brief qres get current budget
235 *
236 *  Retrieve remaining budget for the current server instance.
237 *
238 *  @return status code.
239 */
240RTEMS_INLINE_ROUTINE qos_rv qres_get_curr_budget (
241  qres_sid_t   server_id,
242  qres_time_t *current_budget
243)
244{
245  return _Scheduler_CBS_Get_remaining_budget( server_id, current_budget );
246}
247
248/**
249 *  @brief qres get approved budget
250 *
251 *  Retrieve the budget that has been approved for the subsequent
252 *  server instances.
253 *
254 *  @return status code.
255 */
256RTEMS_INLINE_ROUTINE qos_rv qres_get_appr_budget (
257  qres_sid_t   server_id,
258  qres_time_t *appr_budget
259)
260{
261  return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget );
262}
263
264#ifdef __cplusplus
265}
266#endif
267
268#endif
269/* end of include file */
Note: See TracBrowser for help on using the repository browser.