Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/QNX4/Thread.hpp

Go to the documentation of this file.
00001 // For QNX425
00002 
00003 #ifndef __J2K__Thread_HPP__
00004 #define __J2K__Thread_HPP__
00005 
00006 /**********************************************************************
00007  **  FILE NAME   : <j2k/Fred/QNX/Thread.hpp>                         **
00008  **  CLASS NAME  : Thread                                            **
00009  **  DESCRIPTION : This class allows the creation of                 **
00010  **                Generic Thread which takes care of the internals  **
00011  **                of the QNX OS. Any other subsequent classes can   **
00012  **                use this thread, or can appear as thread just     **
00013  **                by inheriting from this basic class.              **
00014  **********************************************************************/
00015 
00016 #include <j2k/Fred/QNX/System.hpp>
00017 
00018 // Default Arguments
00019 #define  DEFAULT_STACK  4096
00020 #define  DEFAULT_ALGO   SCHED_RR
00021 #define  DEFAULT_PRIO   12
00022 #define  DEFAULT_NODE   0
00023 
00024 // Alias for Scheduling Schemes
00025 #define  S_FIFO         SCHED_FIFO
00026 #define  S_ROUND_ROBIN  SCHED_RR
00027 #define  S_ADAPTIVE     SCHED_OTHER
00028 
00029 // Message Passing Values
00030 #define  MSG_NONE       0
00031 #define  MSG_STOP       1
00032 #define  MSG_REFRESH    2
00033 #define  MSG_YIELD      3
00034 #define  MSG_PRINT      4
00035 #define  MSG_FUNCTION   5
00036 
00037 class Thread {
00038 // MC_SerializeHeader()
00039 
00040 private:
00041   // Not Implemented yet.
00042   Thread( const Thread& thread );  
00043   inline int  yield();  
00044 
00045 public:
00046   // Optimized Default Constructor
00047   inline Thread(); 
00048 
00049 
00050   inline virtual ~Thread();
00051 
00052   static void FAR Thread::Wrapper( void* ptrThis );
00053 
00054   void start( size_t stack_size = DEFAULT_STACK, 
00055                  int       alg  = DEFAULT_ALGO, 
00056                  int       prio = DEFAULT_PRIO  );
00057 
00058   inline void refresh();
00059   inline void stop();
00060 
00061   // Return the Process ID value 
00062   inline pid_t getPID();
00063   inline int isStarted();
00064    
00065   // Should be overriden by it's children...
00066   virtual void run() = 0;
00067 
00068   // Get Initial Starting values
00069   inline size_t  getStack() {          return start_stack; }
00070   inline int     getStartAlgo() {      return start_algo;  }
00071   inline int     getStartPriority() {  return start_prio;  }
00072 
00073   // Get, Set, Reset Priority and Scheduling Schemes
00074   inline int     getPriority();
00075   inline void    setPriority( int prio );
00076   inline void  resetPriority();
00077 
00078   inline int     getScheduler();
00079   inline void    setScheduler( int sched );
00080   inline void  resetScheduler();
00081 
00082   inline struct sched_param*  getSchedulerParam();
00083   inline void                 setSchedulerParam( struct sched_param* param );
00084   inline void               resetSchedulerParam();
00085 
00086 // So, children can access easily the PID
00087 protected: 
00088   pid_t  pid;
00089 
00090   // Not used yet.
00091   pid_t  rpid;
00092   Msg_t  msg;
00093   Msg_t  rmsg;
00094   Msg_t  smsg;
00095 
00096 // Private, since only used by Reset and Restart functions
00097 private:
00098   size_t                start_stack;
00099   int                   start_algo;
00100   int                   start_prio;
00101   struct sched_param*   start_param;
00102 };
00103 
00104 #endif

Generated on Sun Oct 14 18:46:42 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001