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

# oscl_scheduler_readyq.h

Go to the documentation of this file.

    00001
    00013 #ifndef OSCL_SCHEDULER_READYQ_H_INCLUDED
    00014 #define OSCL_SCHEDULER_READYQ_H_INCLUDED
    00015
    00016 #ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED
    00017 #include "oscl_scheduler_types.h"
    00018 #endif
    00019 #ifndef OSCL_SCHEDULER_TUNEABLES_H_INCLUDED
    00020 #include "oscl_scheduler_tuneables.h"
    00021 #endif
    00022
    00023
    00024 #ifndef OSCL_PRIQUEUE_H_INCLUDED
    00025 #include "oscl_priqueue.h"
    00026 #endif
    00027 #ifndef OSCL_BASE_ALLOC_H_INCLUDED
    00028 #include "oscl_base_alloc.h"
    00029 #endif
    00030 #ifndef OSCL_SEMAPHORE_H_INCLUDED
    00031 #include "oscl_semaphore.h"
    00032 #endif
    00033 #ifndef OSCL_MEM_H_INCLUDED
    00034 #include "oscl_mem.h"
    00035 #endif
    00036 #ifndef OSCL_MUTEX_H_INCLUDED
    00037 #include "oscl_mutex.h"
    00038 #endif
    00039 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
    00040 #include "oscl_string_containers.h"
    00041 #endif
    00042
    00043 class PVActiveBase;
    00044
    00045 class OsclReadyAlloc: public Oscl_DefAlloc
    00046 {
    00047     public:
    00048         OsclAny* allocate(const uint32 size) ;
    00049         OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num);
    00050         void deallocate(OsclAny* p) ;
    00051     private:
    00052         OsclMemAllocator iBasicAlloc;
    00053 };
    00054
    00055 typedef PVActiveBase* TOsclReady;
    00056
    00057 class OsclReadyCompare
    00058 {
    00059     public:
    00060         static int compare(TOsclReady& a, TOsclReady& b) ;
    00061 };
    00062 class OsclTimerCompare
    00063 {
    00064     public:
    00065         static int compare(TOsclReady& a, TOsclReady& b) ;
    00066 };
    00067
    00073 class PVLogger;
    00074 class OsclSchedulerObserver;
    00075 class OsclReadyQ
    00076         : public OsclPriorityQueue<TOsclReady, OsclReadyAlloc, Oscl_Vector<TOsclReady, OsclReadyAlloc>, OsclReadyCompare>
    00077 {
    00078     public:
    00079         void Construct(int);
    00080         void ThreadLogon();
    00081         void ThreadLogoff();
    00082
    00083         void Remove(TOsclReady);
    00084
    00085         bool IsIn(TOsclReady);
    00086
    00087         uint32 Depth()
    00088         {
    00089             return size();
    00090         }
    00091
    00092         TOsclReady PopTop();
    00093         TOsclReady Top();
    00094
    00095         TOsclReady WaitAndPopTop();
    00096         TOsclReady WaitAndPopTop(uint32);
    00097
    00098         int32 PendComplete(PVActiveBase *pvbase, int32 aReason);
    00099         int32 WaitForRequestComplete(PVActiveBase*);
    00100
    00101         //For non-blocking scheduler observer support
    00102         void RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext);
    00103         void TimerCallback(uint32 aDelayMicrosec);
    00104         OsclSchedulerObserver* Callback()
    00105         {
    00106             return iCallback;
    00107         }
    00108
    00109     private:
    00110         TOsclReady PopTopAfterWait();
    00111
    00112         //mutex for thread protection
    00113         OsclNoYieldMutex iCrit;
    00114
    00115         //this semaphore tracks the queue size.  it is used to
    00116         //regulate the scheduling loop when running in blocking mode.
    00117         OsclSemaphore iSem;
    00118
    00119         //a sequence number needed to maintain FIFO sorting order in oscl pri queue.
    00120         uint32 iSeqNumCounter;
    00121
    00122         //For non-blocking scheduler observer support
    00123         OsclSchedulerObserver* iCallback;
    00124         OsclAny* iCallbackContext;
    00125 };
    00126
    00127 /*
    00128 ** A non-thread-safe queue for holding pending timers.
    00129 */
    00130 class OsclTimerQ
    00131         : public OsclPriorityQueue<TOsclReady, OsclReadyAlloc, Oscl_Vector<TOsclReady, OsclReadyAlloc>, OsclTimerCompare>
    00132 {
    00133     public:
    00134         void Construct(int);
    00135         void Add(TOsclReady);
    00136         void Remove(TOsclReady);
    00137         TOsclReady PopTop();
    00138         TOsclReady Top();
    00139         void Pop(TOsclReady);
    00140         bool IsIn(TOsclReady);
    00141     private:
    00142         //a sequence number needed to maintain FIFO sorting order in oscl pri queue.
    00143         uint32 iSeqNumCounter;
    00144 };
    00145
    00149 class TReadyQueLink
    00150 {
    00151     public:
    00152         TReadyQueLink()
    00153         {
    00154             iAOPriority = 0;
    00155             iTimeToRunTicks = 0;
    00156             iSeqNum = 0;
    00157             iIsIn = NULL;
    00158         }
    00159
    00160         int32 iAOPriority;//scheduling priority
    00161         uint32 iTimeToRunTicks;//for timers, this is the time to run in ticks.
    00162         uint32 iTimeQueuedTicks;//the time when the AO was queued, in ticks.
    00163         uint32 iSeqNum;//sequence number for oscl pri queue.
    00164         OsclAny* iIsIn;//pointer to the queue we're in, cast as a void*
    00165
    00166 };
    00167
    00168 #endif
    00169
    00170