OS Threading Level Abstraction.


Detailed Description

See OS Threading Abstraction (and Independence) Layer.


Classes

struct  Wefts::tag_ThreadAndReturn
 Utility structure to pass around a thread object along with its return. More...

class  Wefts::OSMutexBase
 Implements an OS specific mutex This mutex class is not supposed to be reentrant, but it is supposed to have an trylock() feature at OS level. More...

class  Wefts::OSConditionBase
 This class implement an os-dependant condition. More...

class  Wefts::OSThreadBase
 Thread OS layer abstraction This class can be rewritten in other header files to implement different os specific threading system. More...

class  Wefts::OSSpecificDataBase
 Wrapper class for thread specific data access (tsd/tls). More...

class  Wefts::OSMutexPthread
class  Wefts::OSConditionPthread
 This class implement an os-dependant condition. More...

class  Wefts::OSThreadPthread
 Wraps Posix threads. More...

class  Wefts::OSSpecificDataPthread
 Wrapper class for pthread specific data access (tsd/tls). More...


Typedefs

typedef Wefts::tag_ThreadAndReturn Wefts::ThreadAndReturn
 Utility structure to pass around a thread object along with its return.

typedef OSSpecificDataPthread Wefts::OSSpecificData
 Function to execute the thread RUN procedure guarded by OS cleanup.

typedef OSThreadPthread Wefts::OSThread
typedef OSConditionPthread Wefts::OSCondition
typedef OSMutexPthread Wefts::OSMutex

Enumerations

enum  Wefts::OSPriority {
  Wefts::PrioRealTime = 0, Wefts::PrioHigh = 1, Wefts::PrioNormal = 2, Wefts::PrioLow = 3,
  Wefts::PrioIdle = 4
}
 Portable priority concept. More...


Functions

std::string Wefts::OSErrorDescription (int osCode)
 Function to report OS specific error.

bool Wefts::OSSleep (long nSeconds, long nNanoseconds)
 Function to provide a wefts-interruptable wait.

void * Wefts::getCurrentThreadObject ()
 Function that returns the thread object running in the current OS thread.

void Wefts::setCurrentThreadObject (void *thread)
 Function used to set current thread object.

void Wefts::wefts_pthread_cond_guard (void *param)
 This function is used internally by pthread module to safely guard the condition on async cancellation.

void Wefts::wefts_pthread_cond_reset (void *param)


Typedef Documentation

typedef OSConditionWindows Wefts::OSCondition
 

typedef OSMutexWindows Wefts::OSMutex
 

typedef OSSpecificDataWindows Wefts::OSSpecificData
 

Function to execute the thread RUN procedure guarded by OS cleanup.

typedef OSThreadWindows Wefts::OSThread
 

typedef struct Wefts::tag_ThreadAndReturn Wefts::ThreadAndReturn
 

Utility structure to pass around a thread object along with its return.

As the only function able to know if a thread is detached, and that then can rightfully delete the thread object, is the cancellation cleanup handler, it is also the only function that is able to set the thread run return value member if the thread is NOT detached. To let the cleanup handler have this value, this structure holds a pointer to the thread and a pointer to the run return value (or zero, if the run() method had not a chance to return).

OSThreadBase::osRun() is responsible to fill correctly this value and let the cleanup routine have it.


Enumeration Type Documentation

enum Wefts::OSPriority
 

Portable priority concept.

This is a set of priorities that can be used to modify a thread priority in the internal scheduling policy.

Enumeration values:
PrioRealTime  Realtime priority.

Theads in this class should be rescheduled and executed as fast as the operating system is able to do, pre-empting even the Kernel, if the OS is able to cope with this.

PrioHigh  High priority.

Theads in this class should be rescheduled and executed as fast as the operating system is able to do, but the kernel is not pre-empted under any condition.

PrioNormal  Normal priority.

The thread is just scheduled in the normal thread queues, which means that it's waken as soon as possible, after that system kernel, interrupts/signal handlers and device driver/service routines have completed or are considered "idle".

PrioLow  Low priority.

Threads in this class are considered low priority, and awaken only if/when the normal priority threads are idle; anyhow, care is taken not to starve this thread class, so a little space should be found for them anyway, maybe with big delays.

PrioIdle  Idle threads.

Threads in this class are waken up only during the system Idle cycle, so that they are actually running only if no other process (including the kernel) is actively demanding CPU. Idle thread class may be starved indefinitely, if the CPU is so intensely exploited that it never enters the idle loop.


Function Documentation

void* getCurrentThreadObject  ) 
 

Function that returns the thread object running in the current OS thread.

It may be null if current OS thread has not be started with Thread::run(); tipically calling this from the main thread will return 0. If you use only Wefts to start threads, you can safely use the return vaule of 0 as a marker for the main application thread.

Returns:
a pointer that can be casted into a Wefts::Thread object.

std::string OSErrorDescription int  osCode  ) 
 

Function to report OS specific error.

bool OSSleep long  nSeconds,
long  nNanoseconds
 

Function to provide a wefts-interruptable wait.

void setCurrentThreadObject void *  thread  ) 
 

Function used to set current thread object.

OSTAIL providers must provide this function, that is called by threads right before calling the Thread::run() method. This is used internally for various reasons.a

Parameters:
thread the object whose Thread::run() method is going to be called.

void wefts_pthread_cond_guard void *  param  ) 
 

This function is used internally by pthread module to safely guard the condition on async cancellation.

void wefts_pthread_cond_reset void *  param  ) 
 


Generated on Tue Oct 5 14:57:01 2004 for Wefts by doxygen 1.3.7