Main Page   Modules   Class Hierarchy   Data Structures   File List   Data Fields   Globals   Related Pages  

oscl_scheduler_aobase.h

Go to the documentation of this file.
00001 
00015 #ifndef OSCL_SCHEDULER_AOBASE_H_INCLUDED
00016 #define OSCL_SCHEDULER_AOBASE_H_INCLUDED
00017 
00018 #ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED
00019 #include "oscl_scheduler_types.h"
00020 #endif
00021 
00022 #ifndef OSCL_NAMESTRING_H_INCLUDED
00023 #include "oscl_namestring.h"
00024 #endif
00025 
00026 #ifndef OSCL_SCHEDULER_THREAD_CONTEXT_H_INCLUDED
00027 #include "oscl_scheduler_threadcontext.h"
00028 #endif
00029 
00030 #ifndef OSCL_SCHEDULER_READYQ_H_INCLUDED
00031 #include "oscl_scheduler_readyq.h"
00032 #endif
00033 
00034 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
00035 #include "oscl_string_containers.h"
00036 #endif
00037 
00038 /*
00039  * Macro for zeroizing the memory of a newly created object
00040  *
00041  * @param ptr   pointer to the newly created object
00042  *
00043  * @param size  size of the memory
00044  */
00045 
00046 #define OSCL_ZEROIZE(ptr, size) oscl_memset(ptr, 0, size)
00047 
00048 /*
00049 ** Max length for scheduler and AO names.
00050 */
00051 #define PVEXECNAMELEN 30
00052 
00053 #if (PV_SCHED_ENABLE_AO_STATS)
00054 
00056 class PVActiveStats
00057 {
00058     private:
00059         //should be constructed only when AO is added to scheduler.
00060         PVActiveStats(OsclExecSchedulerCommonBase* aScheduler, const char* aAOName, PVActiveBase* aActiveBase);
00061         ~PVActiveStats();
00062 
00063         void Combine(PVActiveStats&);
00064 
00065         //Queue link for scheduler iPVStatQ
00066         OsclDoubleLink iPVStatQLink;
00067 
00068         //this AO's scheduler
00069         OsclExecSchedulerCommonBase* iScheduler;
00070         //AO name
00071         OSCL_HeapString<OsclMemAllocator> iAOName;
00072         //pointer to original container object.
00073         PVActiveBase* iPVActiveBase;
00074 
00075         uint32 iNumRun;//how many Run calls
00076         uint32 iNumRunError;//how many RunError calls
00077         int32 iMaxTicksInRun;//max time in any one Run call
00078 
00079         uint32 iTotalTicksInRun;
00080 
00081         bool i64Valid;//use 64-bit stats instead of 32-bit
00082         int64 i64TotalTicksInRun;//avg number of clock ticks per Run
00083 
00084         //for internal computation-- percent of total time in this Run
00085         float iPercent;
00086 
00087         int32 iLeave;//last leave code from a Run call
00088         uint32 iNumCancel;//how many DoCancel calls.
00089 
00090         uint32 iNumInstances;//number of scheduler instances of this AO.
00091         int32 iPriority;//scheduler priority
00092 
00093         friend class PVActiveBase;
00094         friend class OsclExecScheduler;
00095         friend class OsclExecSchedulerCommonBase;
00096         friend class OsclActiveObject;
00097         friend class OsclTimerObject;
00098         friend class OsclReadyQ;
00099 };
00100 #endif //(PV_SCHED_ENABLE_AO_STATS)
00101 
00102 
00110 class PVActiveBase
00111 {
00112     public:
00113         uint32 iAddedNum;
00114 
00115 //iStatus, AddToScheduler(), RemoveFromScheduler etc are needed in PVSchedulerStopper (which is publically derived from OsclActiveObject and OsclActiveObject is publically derived from PVActiveBase )
00116 //protected:
00117 
00118         PVActiveBase(const char name[], int32 pri);
00119 
00120         virtual ~PVActiveBase();
00121 
00122         /*
00123         ** Each AO has a name, to aid in statistics reporting and debugging.
00124         */
00125         OsclNameString<PVEXECNAMELEN> iName;
00126 
00127         /*
00128         ** Each AO knows its thread context, including a pointer to the scheduler
00129         ** that it is in.
00130         */
00131         PVThreadContext iThreadContext;
00132 
00133 #if (PV_SCHED_ENABLE_AO_STATS)
00134         /*
00135         ** AO statistics
00136         */
00137         PVActiveStats *iPVActiveStats;
00138         friend class PVActiveStats;
00139 #endif
00140 
00141 
00142         /*
00143         ** Non-Symbian AO implementation.
00144         */
00145 
00146         /*
00147         ** Queue link for scheduler iExecTimerQ or iReadyQ.
00148         */
00149         TReadyQueLink iPVReadyQLink;
00150 
00151         /*
00152         ** Return true if this AO is in any queue.
00153         */
00154         bool IsInAnyQ()
00155         {
00156             return(iPVReadyQLink.iIsIn != NULL);
00157         }
00158 
00159         /*
00160         ** The executing flag is set whenever a request is active (pending
00161         ** or complete).  The AO is de-activated by scheduler just before
00162         ** calling the Run.
00163         */
00164         bool iBusy;
00165 
00184         OsclAOStatus iStatus;
00185 
00193         virtual int32 RunError(int32 aError) = 0;
00194 
00221         virtual void Run() = 0;
00222 
00234         virtual void DoCancel() = 0;
00235 
00236         /*
00237         ** Common methods to support OsclActiveObject and OsclTimerObject APIs
00238         */
00239         void AddToScheduler();
00240         void RemoveFromScheduler();
00241         void Destroy();
00242         void Activate();
00243         OSCL_IMPORT_REF bool IsAdded()const;
00244         void Cancel();
00245 
00246         friend class OsclSchedulerCommonBase;
00247         friend class OsclActiveObject;
00248         friend class OsclTimerObject;
00249         friend class OsclReadyQ;
00250         friend class OsclReadyCompare;
00251         friend class OsclReadySetPosition;
00252         friend class OsclExecScheduler;
00253 
00254 };
00255 
00256 #endif
00257 
00258 
00259 
00260 

OSCL API
Posting Version: CORE_8.000.1.1_RC4