00001 /* 00002 * RKTask.hh 00003 * 00004 * Copyright (c) 2003 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 RKTask.hh 00014 * 00015 * Header file for the TimeSys implementation of Broker::RealTimeTask. 00016 */ 00017 00018 #ifndef _task_impl_hh 00019 #define _task_impl_hh 00020 00021 #include <rk.h> 00022 00023 #include "BrokerS.h" 00024 00025 /** 00026 * An implementation of Broker::RealTimeTask for the TimeSys resource kernel. 00027 * The class will create an rk_resource_set for every process on construction 00028 * and maintain it until destruction. 00029 */ 00030 class RKTask : public virtual POA_Broker::RealTimeTask 00031 { 00032 00033 public: 00034 00035 /** 00036 * Construct an RKTask from the given parameters. The current set of 00037 * recognized parameters are: 00038 * 00039 * @li @e name A string to be used as the name of the task. (@e required) 00040 * @li @e pid A long that contains the process ID to manage. (@e required) 00041 * 00042 * @param tp The list of parameters. 00043 * 00044 * @exception CORBA::SystemException for CORBA related errors. 00045 * @exception Broker::InvalidTaskParameter if one of the parameters is 00046 * invalid. 00047 * @exception Broker::MissingTaskParameter if one of the required 00048 * parameters is missing. 00049 */ 00050 RKTask(const Broker::TaskParameters &tp) 00051 throw (CORBA::SystemException, 00052 Broker::DuplicateTaskParameter, 00053 Broker::InvalidTaskParameter, 00054 Broker::MissingTaskParameter); 00055 00056 /** 00057 * Destruct an RKTask. 00058 */ 00059 virtual ~RKTask(); 00060 00061 /** @copydoc Broker::Task::Name */ 00062 char *Name(void) 00063 throw (CORBA::SystemException); 00064 00065 /** @copydoc Broker::RealTimeTask::Period */ 00066 CORBA::ULong Period(void) 00067 throw (CORBA::SystemException); 00068 00069 /** @copydoc Broker::RealTimeTask::Deadline */ 00070 CORBA::ULong Deadline(void) 00071 throw (CORBA::SystemException); 00072 00073 /** @copydoc Broker::Task::BeginCPUScheduling */ 00074 void BeginCPUScheduling(Broker::Manager_ptr manager, 00075 const Broker::ScheduleParameters &cs) 00076 throw (CORBA::SystemException, 00077 Broker::DuplicateScheduleParameter, 00078 Broker::InvalidScheduleParameter, 00079 Broker::MissingScheduleParameter); 00080 00081 /** @copydoc Broker::Task::EndCPUScheduling */ 00082 void EndCPUScheduling(void) 00083 throw (CORBA::SystemException); 00084 00085 /** @copydoc Broker::RealTimeTask::GetComputeTime */ 00086 CORBA::ULong GetComputeTime(void) 00087 throw (CORBA::SystemException); 00088 00089 /** @copydoc Broker::RealTimeTask::SetComputeTime */ 00090 void SetComputeTime(CORBA::ULong usecs) 00091 throw (CORBA::SystemException); 00092 00093 protected: 00094 00095 /** 00096 * The name of the task and the resource set created for it. 00097 * 00098 * @invariant != NULL 00099 */ 00100 CORBA::String_var rkt_Name; 00101 00102 /** 00103 * The resource set for the process. 00104 * 00105 * @invariant != NULL 00106 */ 00107 rk_resource_set_t rkt_ResourceSet; 00108 00109 /** 00110 * Caches the value of the CPU reservation when scheduling is active and 00111 * maintains the values when not active. 00112 * 00113 * @invariant .compute_time <= .period 00114 * @invariant .deadline <= .period 00115 */ 00116 struct cpu_reserve_attr rkt_CPUReserveSpec; 00117 00118 /** 00119 * The Broker::Manager used to handle scheduling during contention. Only 00120 * valid between #BeginCPUScheduling and #EndCPUScheduling calls. 00121 */ 00122 Broker::Manager_var rkt_Manager; 00123 00124 /** 00125 * The CPU reserve for the process. Only valid between #BeginCPUScheduling 00126 * and #EndCPUScheduling calls. 00127 */ 00128 rk_reserve_t rkt_CPUReserve; 00129 00130 struct timeval rkt_StartTime; 00131 00132 struct timeval rkt_LastReservationLog; 00133 00134 ofstream *rkt_ReservationLog; 00135 00136 }; 00137 00138 #endif