Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

rt_scheduler.h

Go to the documentation of this file.
00001 /*
00002  * rt_scheduler.h
00003  *
00004  * Copyright (c) 2004 The University of Utah and the Flux Group.
00005  * All rights reserved.
00006  *
00007  * This file is licensed under the terms of the GNU Public License.  
00008  * See the file "license.terms" for restrictions on redistribution 
00009  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  */
00011 
00012 /**
00013  * @file rt_scheduler.h
00014  *
00015  * Common interface for using an OS-level real-time scheduler.  @note This is
00016  * just an interface, there is no default implementation available, the
00017  * appropriate one must be selected and linked in.
00018  *
00019  * @sa rt_scheduler_unix.c
00020  * @sa rt_scheduler_rk.c
00021  */
00022 
00023 #ifndef _misc_rt_scheduler_h
00024 #define _misc_rt_scheduler_h
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 #include <sys/types.h>
00031 #include <sys/time.h>
00032 
00033 enum {
00034     RSDB_RESERVATIONS,
00035 };
00036 
00037 enum {
00038     /** The scheduler supports CPU reservations. */
00039     RSDF_RESERVATIONS = (1L << RSDB_RESERVATIONS),
00040 };
00041 
00042 /*
00043  * Data structure used to communicate information about the properties of the
00044  * underlying scheduler.
00045  *
00046  * rsd_Flags - Field used to store RSDF_RESERVATIONS.
00047  * rsd_MaxReservable - The maximum fraction of CPU that can be reserve.
00048  */
00049 typedef struct rts_scheduler_data {
00050     unsigned long rsd_Flags;
00051     float rsd_MaxReservable;
00052 } *rts_scheduler_data_t;
00053 
00054 /**
00055  * Get information about the underlying scheduler.  This function is mostly
00056  * about making it possible to do run-time adaptation to the scheduler's
00057  * capabilities.
00058  *
00059  * @param rsd_out A reference to an #rts_scheduler_data object that should be
00060  * filled in.
00061  */
00062 extern int rts_query_scheduler(rts_scheduler_data_t rsd_out);
00063 
00064 /**
00065  * An opaque reference to scheduler specific data.  The schedulable is used to
00066  * collect multiple processes under a single schedulable entity.  For example,
00067  * TimeSys Linux schedules a "resource set", which in turn, schedules a process
00068  * in that set.
00069  *
00070  * @see rts_grab_schedulable
00071  * @see rts_release_schedulable
00072  */
00073 typedef void *rts_schedulable_t;
00074 
00075 /**
00076  * Grab a reference to a schedulable entity.  The current semantics of this
00077  * function are as follows:
00078  *
00079  * @li If necessary, the function must make some effort to "repair" the system
00080  * state by destroying schedulables that are in a suspicious state.
00081  * @li Multiple calls to this function with the same parameters need not return
00082  * the same pointer, however, their values must be equal.  The user must also
00083  * release the schedulables in the opposite order in which they were grabbed.
00084  * @li If the schedulable entity already exists at the OS-level, it should be
00085  * used instead of creating a new one.
00086  * @li If no schedulable entity exists that contains the given process or has
00087  * the given name, one should be created.
00088  *
00089  * @param rs_out A pointer that should be filled out with the schedulable
00090  * value.
00091  * @param member A process that is already a member of the schedulable, one
00092  * that should be added to a newly created schedulable, or -1 if the
00093  * schedulable should be created by name.
00094  * @param name The name for the schedulable or NULL if one should be made up.
00095  * @return Zero on success, otherwise, an errno code.
00096  */
00097 extern int rts_grab_schedulable(rts_schedulable_t *rs_out,
00098                                 pid_t member,
00099                                 const char *name);
00100 
00101 /**
00102  * Release a reference to a schedulable entity.  The current semantics of this
00103  * function are as follows:
00104  *
00105  * @li If the given schedulable created the OS-level entity, this call should
00106  * destroy it.
00107  * @li If the given schedulable entity was used to set the schedule, this call
00108  * should clear the schedule.
00109  *
00110  * @param rs The reference from #rts_grab_schedulable to release.
00111  * @return Zero on success, otherwise an errno value.
00112  */
00113 extern int rts_release_schedulable(rts_schedulable_t rs);
00114 
00115 /**
00116  * The reservation mode.
00117  */
00118 typedef enum {
00119     RTS_RSV_MIN,        /**< Minimum allowed value. */
00120     RTS_RSV_SOFT,       /**< Soft reservation - use best-effort when needed. */
00121     RTS_RSV_HARD,       /**< Hard reservation - never use best-effort. */
00122     RTS_RSV_MAX         /**< Maximum allowed value. */
00123 } rts_reserve_mode_t;
00124 
00125 /*
00126  * A description of the schedulable's CPU schedule.
00127  *
00128  * rs_Period - The schedulable's period.
00129  * rs_ComputeTime - The schedulable's compute time.
00130  * rs_ReserveMode - The schedulable's reservation mode.
00131  */
00132 typedef struct rts_schedule {
00133     struct timespec rs_Period;
00134     struct timespec rs_ComputeTime;
00135     rts_reserve_mode_t rs_ReserveMode;
00136 } *rts_schedule_t;
00137 
00138 /**
00139  * Set the real-time schedule for a schedulable.
00140  *
00141  * @param rsa The schedulable to schedule.
00142  * @param rs The new schedule.
00143  * @return Zero on success, otherwise, an errno code.
00144  */
00145 extern int rts_set_schedule(rts_schedulable_t rsa, rts_schedule_t rs);
00146 
00147 /**
00148  * Get the real-time schedule for a schedulable.
00149  *
00150  * @param rsa The schedulable to schedule.
00151  * @param rs_out The new schedule.
00152  * @return Zero on success, otherwise, an errno code.
00153  */
00154 extern int rts_get_schedule(rts_schedulable_t rsa, rts_schedule_t rs_out);
00155 
00156 /**
00157  * Clear the real-time schedule for a schedulable and return it to a
00158  * best-effort scheduler.
00159  *
00160  * @param rsa The schedulable to clear.
00161  * @return Zero on success, otherwise, an errno code.
00162  */
00163 extern int rts_clear_schedule(rts_schedulable_t rsa);
00164 
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168 
00169 #endif

Generated on Fri Oct 22 07:50:24 2004 for CPU Broker by  doxygen 1.3.9.1