RTEMS CPU Kit with SuperCore  4.10.99.0
rtems/score/schedulercbs.h
Go to the documentation of this file.
00001 
00010 /*
00011  *  Copryight (c) 2011 Petr Benes.
00012  *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
00013  *
00014  *  The license and distribution terms for this file may be
00015  *  found in the file LICENSE in this distribution or at
00016  *  http://www.rtems.org/license/LICENSE.
00017  */
00018 
00019 #ifndef _RTEMS_SCORE_SCHEDULERCBS_H
00020 #define _RTEMS_SCORE_SCHEDULERCBS_H
00021 
00022 #include <rtems/score/chain.h>
00023 #include <rtems/score/priority.h>
00024 #include <rtems/score/scheduler.h>
00025 #include <rtems/score/rbtree.h>
00026 #include <rtems/score/scheduleredf.h>
00027 #include <rtems/rtems/signal.h>
00028 #include <rtems/rtems/timer.h>
00029 #include <rtems/score/thread.h>
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00048 #define SCHEDULER_CBS_ENTRY_POINTS \
00049   { \
00050     _Scheduler_EDF_Initialize,       /* initialize entry point */ \
00051     _Scheduler_EDF_Schedule,         /* schedule entry point */ \
00052     _Scheduler_EDF_Yield,            /* yield entry point */ \
00053     _Scheduler_EDF_Block,            /* block entry point */ \
00054     _Scheduler_CBS_Unblock,          /* unblock entry point */ \
00055     _Scheduler_CBS_Allocate,         /* allocate entry point */ \
00056     _Scheduler_default_Free,         /* free entry point */ \
00057     _Scheduler_EDF_Update,           /* update entry point */ \
00058     _Scheduler_EDF_Enqueue,          /* enqueue entry point */ \
00059     _Scheduler_EDF_Enqueue_first,    /* enqueue_first entry point */ \
00060     _Scheduler_EDF_Extract,          /* extract entry point */ \
00061     _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
00062     _Scheduler_CBS_Release_job,      /* new period of task */ \
00063     _Scheduler_default_Tick,         /* tick entry point */ \
00064     _Scheduler_default_Start_idle    /* start idle entry point */ \
00065   }
00066 
00067 /* Return values for CBS server. */
00068 #define SCHEDULER_CBS_OK                        0
00069 #define SCHEDULER_CBS_ERROR_GENERIC            -16
00070 #define SCHEDULER_CBS_ERROR_NO_MEMORY          -17
00071 #define SCHEDULER_CBS_ERROR_INVALID_PARAMETER  -18
00072 #define SCHEDULER_CBS_ERROR_UNAUTHORIZED       -19
00073 #define SCHEDULER_CBS_ERROR_UNIMPLEMENTED      -20
00074 #define SCHEDULER_CBS_ERROR_MISSING_COMPONENT  -21
00075 #define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22
00076 #define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD    -23
00077 #define SCHEDULER_CBS_ERROR_INTERNAL_ERROR     -24
00078 #define SCHEDULER_CBS_ERROR_NOT_FOUND          -25
00079 #define SCHEDULER_CBS_ERROR_FULL               -26
00080 #define SCHEDULER_CBS_ERROR_EMPTY              -27
00081 #define SCHEDULER_CBS_ERROR_NOSERVER           SCHEDULER_CBS_ERROR_NOT_FOUND
00082 
00084 extern const uint32_t _Scheduler_CBS_Maximum_servers;
00085 
00087 typedef uint32_t Scheduler_CBS_Server_id;
00088 
00090 typedef void (*Scheduler_CBS_Budget_overrun)(
00091     Scheduler_CBS_Server_id server_id
00092 );
00093 
00097 typedef struct {
00099   time_t deadline;
00101   time_t budget;
00102 } Scheduler_CBS_Parameters;
00103 
00107 typedef struct {
00113   rtems_id                 task_id;
00115   Scheduler_CBS_Parameters parameters;
00117   Scheduler_CBS_Budget_overrun  cbs_budget_overrun;
00118 
00124   bool initialized;
00125 } Scheduler_CBS_Server;
00126 
00130 typedef struct {
00132   Scheduler_EDF_Per_thread      edf_per_thread;
00134   Scheduler_CBS_Server         *cbs_server;
00135 } Scheduler_CBS_Per_thread;
00136 
00137 
00142 extern Scheduler_CBS_Server _Scheduler_CBS_Server_list[];
00143 
00157 void _Scheduler_CBS_Unblock(
00158   const Scheduler_Control *scheduler,
00159   Thread_Control          *the_thread
00160 );
00161 
00174 void _Scheduler_CBS_Release_job (
00175   const Scheduler_Control *scheduler,
00176   Thread_Control          *the_thread,
00177   uint32_t                 length
00178 );
00179 
00187 int _Scheduler_CBS_Initialize(void);
00188 
00196 int _Scheduler_CBS_Attach_thread (
00197   Scheduler_CBS_Server_id server_id,
00198   rtems_id                task_id
00199 );
00200 
00208 int _Scheduler_CBS_Detach_thread (
00209   Scheduler_CBS_Server_id server_id,
00210   rtems_id                task_id
00211 );
00212 
00220 int _Scheduler_CBS_Cleanup (void);
00221 
00229 int _Scheduler_CBS_Create_server (
00230   Scheduler_CBS_Parameters     *params,
00231   Scheduler_CBS_Budget_overrun  budget_overrun_callback,
00232   rtems_id                     *server_id
00233 );
00234 
00244 int _Scheduler_CBS_Destroy_server (
00245   Scheduler_CBS_Server_id server_id
00246 );
00247 
00256 int _Scheduler_CBS_Get_approved_budget (
00257   Scheduler_CBS_Server_id  server_id,
00258   time_t                  *approved_budget
00259 );
00260 
00268 int _Scheduler_CBS_Get_remaining_budget (
00269   Scheduler_CBS_Server_id  server_id,
00270   time_t                  *remaining_budget
00271 );
00272 
00284 int _Scheduler_CBS_Get_execution_time (
00285   Scheduler_CBS_Server_id   server_id,
00286   time_t                   *exec_time,
00287   time_t                   *abs_time
00288 );
00289 
00297 int _Scheduler_CBS_Get_parameters (
00298   Scheduler_CBS_Server_id   server_id,
00299   Scheduler_CBS_Parameters *params
00300 );
00301 
00310 int _Scheduler_CBS_Get_server_id (
00311   rtems_id                 task_id,
00312   Scheduler_CBS_Server_id *server_id
00313 );
00314 
00325 int _Scheduler_CBS_Set_parameters (
00326   Scheduler_CBS_Server_id   server_id,
00327   Scheduler_CBS_Parameters *parameters
00328 );
00329 
00335 void _Scheduler_CBS_Budget_callout(
00336   Thread_Control *the_thread
00337 );
00338 
00347 bool _Scheduler_CBS_Allocate(
00348   const Scheduler_Control *scheduler,
00349   Thread_Control          *the_thread
00350 );
00351 
00352 #ifdef __cplusplus
00353 }
00354 #endif
00355 
00358 #endif
00359 /* end of include file */