PPL Logo

conv-core/threads.c File Reference

Go to the source code of this file.

Data Structures

struct  CthThreadBase
struct  CthThreadStruct
struct  CthProcInfo
struct  CthThreadStruct
struct  CthThreadStruct
struct  CthThreadStruct
struct  CthThreadStruct

Typedefs

typedef struct CthProcInfoCthProcInfo
typedef VOID(WINAPI * PFIBER_START_ROUTINE )(LPVOID lpFiberParameter)
typedef PFIBER_START_ROUTINE LPFIBER_START_ROUTINE
typedef CthThreadthreadTable
typedef void(* uJcontext_fn_t )(void)

Functions

int CmiThreadIs (int flag)
CthThreadTokenCthGetToken (CthThread t)
 CpvStaticDeclare (int, Cth_serialNo)
int CthAliasCreate (int stackSize)
 Create an aliasable area of this size.
void CthAliasFree (int fd)
void CthAliasEnable (CthThreadBase *t)
 CthCpvStatic (CthThread, CthCurrent)
 CthCpvDeclare (char *, CthData)
 CthCpvStatic (int, CthDatasize)
void CthSetThreadID (CthThread th, int a, int b, int c)
CmiObjIdCthGetThreadID (CthThread th)
char * CthGetData (CthThread t)
static void CthFixData (CthThread t)
int CthRegister (int size)
 Allocate another size bytes of thread-local storage, and return the offset into the thread storage buffer.
void CthRegistered (int maxOffset)
 Make sure we have room to store up to at least maxOffset bytes of thread-local storage.
 CthCpvStatic (int, _defaultStackSize)
void CthSetSerialNo (CthThread t, int no)
static void CthThreadBaseInit (CthThreadBase *th)
static void * CthAllocateStack (CthThreadBase *th, int *stackSize, int useMigratable)
static void CthThreadBaseFree (CthThreadBase *th)
 CpvDeclare (int, _numSwitches)
static void CthBaseInit (char **argv)
int CthImplemented ()
CthThread CthSelf ()
void CthPupBase (pup_er p, CthThreadBase *t, int useMigratable)
static void CthThreadFinished (CthThread t)
void CthSetSuspendable (CthThread t, int val)
int CthIsSuspendable (CthThread t)
void CthSetNext (CthThread t, CthThread v)
CthThread CthGetNext (CthThread t)
static void CthNoStrategy (void)
void CthSetStrategy (CthThread t, CthAwkFn awkfn, CthThFn chsfn)
static void CthBaseResume (CthThread t)
void CthSwitchThread (CthThread t)
 switch the thread to t
void CthSuspend (void)
void CthAwaken (CthThread th)
void CthYield ()
void CthAwakenPrio (CthThread th, int s, int pb, unsigned int *prio)
void CthYieldPrio (int s, int pb, unsigned int *prio)
void CthAddListener (CthThread t, struct CthThreadListener *l)
 This listener is about to begin receiving suspend and resume events for this thread.
int CthMigratable ()
CthThread CthPup (pup_er p, CthThread t)
 CthCpvDeclare (CthProcInfo, CthProc)
static void CthThreadInit (CthThread t, CthVoidFn fn, void *arg)
static void CthThreadFree (CthThread t)
void CthFree (CthThread t)
void CthDummy ()
void CthInit (char **argv)
static void CthOnly (CthThread t, void *dum1, void *dum2)
size_t CthStackOffset (CthThread t, char *p)
char * CthPointer (CthThread t, size_t pos)
static void CthResume1 (qt_t *sp, CthProcInfo proc, CthThread t)
void CthResume (CthThread t)
CthThread CthCreate (CthVoidFn fn, void *arg, int size)
CthThread CthCreateMigratable (CthVoidFn fn, void *arg, int size)
WINBASEAPI LPVOID WINAPI CreateFiber (DWORD dwStackSize, LPFIBER_START_ROUTINE lpStartAddress, LPVOID lpParameter)
WINBASEAPI LPVOID WINAPI CreateFiberEx (SIZE_T dwStackCommitSize, SIZE_T dwStackReserveSize, DWORD dwFlags, LPFIBER_START_ROUTINE lpStartAddress, LPVOID lpParameter)
WINBASEAPI VOID WINAPI DeleteFiber (LPVOID lpFiber)
WINBASEAPI LPVOID WINAPI ConvertThreadToFiber (LPVOID lpParameter)
WINBASEAPI VOID WINAPI SwitchToFiber (LPVOID lpFiber)
WINBASEAPI BOOL WINAPI SwitchToThread (VOID)
 CthCpvStatic (CthThread, CthPrevious)
 CthCpvStatic (int, tablesize)
 CthCpvStatic (threadTable, exitThreads)
 CthCpvStatic (int, nExit)
static void CthThreadInit (CthThread t)
static void CthClearThreads ()
void CthFiberBlock (CthThread t)
VOID CALLBACK FiberSetUp (PVOID fiberData)
 CthCpvStatic (pthread_mutex_t, sched_mutex)
 The sched_mutex is the current token of execution.
static void * CthOnly (void *arg)
 CpvStaticDeclare (CthThread, doomedThreadPool)
void CthStartThread (CmiUInt4 fn1, CmiUInt4 fn2, CmiUInt4 arg1, CmiUInt4 arg2)
void CthStartThread (qt_userf_t fn, void *arg)
int ptrDiffLen (const void *a, const void *b)
static CthThread CthCreateInner (CthVoidFn fn, void *arg, int size, int migratable)
void setProtection (char *, char *, int, int)
static CthThread CthThreadInit (void)
static void * CthAbortHelp (qt_t *sp, CthThread old, void *null)
static void * CthBlockHelp (qt_t *sp, CthThread old, void *null)
static void CthOnly (void *arg, void *vt, qt_userf_t fn)
void CthPrintThdStack (CthThread t)
void CthTraceResume (CthThread t)
void CthPrintThdMagic (CthThread t)

Variables

static int CmiThreadIs_flag = 0
CthThreadBase_curMappedStack = 0
 CthAliasEnable brings this thread's stack into memory.


Typedef Documentation

typedef struct CthProcInfo* CthProcInfo

Definition at line 824 of file threads.c.

typedef VOID(WINAPI * PFIBER_START_ROUTINE)(LPVOID lpFiberParameter)

Definition at line 1049 of file threads.c.

Definition at line 1052 of file threads.c.

Definition at line 1115 of file threads.c.

typedef void(* uJcontext_fn_t)(void)

Definition at line 1506 of file threads.c.


Function Documentation

int CmiThreadIs ( int  flag  ) 

Definition at line 184 of file threads.c.

Referenced by checkAddress(), and meta_malloc().

CthThreadToken* CthGetToken ( CthThread  t  ) 

Definition at line 194 of file threads.c.

Referenced by CthResumeSchedulingThread().

CpvStaticDeclare ( int  ,
Cth_serialNo   
)

int CthAliasCreate ( int  stackSize  ) 

Create an aliasable area of this size.

Returns alias handle.

Definition at line 238 of file threads.c.

References CmiAbort(), and write().

Referenced by CthAllocateStack().

void CthAliasFree ( int  fd  ) 

Definition at line 256 of file threads.c.

Referenced by CthThreadBaseFree().

void CthAliasEnable ( CthThreadBase t  ) 

CthCpvStatic ( CthThread  ,
CthCurrent   
)

CthCpvDeclare ( char *  ,
CthData   
)

CthCpvStatic ( int  ,
CthDatasize   
)

void CthSetThreadID ( CthThread  th,
int  a,
int  b,
int  c 
)

CmiObjId* CthGetThreadID ( CthThread  th  ) 

Definition at line 324 of file threads.c.

Referenced by traceThreadListener_resume().

char* CthGetData ( CthThread  t  ) 

Definition at line 329 of file threads.c.

static void CthFixData ( CthThread  t  )  [inline, static]

Definition at line 338 of file threads.c.

References data, and realloc().

Referenced by CthBaseResume(), CthRegister(), CthRegistered(), and CthThreadBaseInit().

int CthRegister ( int  size  ) 

Allocate another size bytes of thread-local storage, and return the offset into the thread storage buffer.

Definition at line 355 of file threads.c.

References CthFixData(), and CthThreadBase::data.

Referenced by Cpthread_key_create().

void CthRegistered ( int  maxOffset  ) 

Make sure we have room to store up to at least maxOffset bytes of thread-local storage.

Definition at line 374 of file threads.c.

References CthFixData(), and CthThreadBase::data.

CthCpvStatic ( int  ,
_defaultStackSize   
)

void CthSetSerialNo ( CthThread  t,
int  no 
)

Definition at line 386 of file threads.c.

static void CthThreadBaseInit ( CthThreadBase th  )  [static]

static void* CthAllocateStack ( CthThreadBase th,
int stackSize,
int  useMigratable 
) [static]

static void CthThreadBaseFree ( CthThreadBase th  )  [static]

CpvDeclare ( int  ,
_numSwitches   
)

static void CthBaseInit ( char **  argv  )  [static]

Definition at line 487 of file threads.c.

References CmiGetArgIntDesc().

Referenced by CthInit().

int CthImplemented ( void   ) 

Definition at line 512 of file threads.c.

CthThread CthSelf ( void   ) 

void CthPupBase ( pup_er  p,
CthThreadBase t,
int  useMigratable 
)

static void CthThreadFinished ( CthThread  t  )  [static]

Definition at line 628 of file threads.c.

References CthSuspend().

Referenced by CthOnly(), CthStartThread(), and FiberSetUp().

void CthSetSuspendable ( CthThread  t,
int  val 
)

Definition at line 637 of file threads.c.

int CthIsSuspendable ( CthThread  t  ) 

Definition at line 638 of file threads.c.

void CthSetNext ( CthThread  t,
CthThread  v 
)

Definition at line 640 of file threads.c.

Referenced by CfutureWait(), CkWaitFutureID(), and CthResumeSchedulingThread().

CthThread CthGetNext ( CthThread  t  ) 

Definition at line 641 of file threads.c.

Referenced by CfutureAwaken(), CthSuspendSchedulingThread(), and setFuture().

static void CthNoStrategy ( void   )  [static]

Definition at line 643 of file threads.c.

References CmiAbort().

Referenced by CthAwaken(), CthAwakenPrio(), and CthSuspend().

void CthSetStrategy ( CthThread  t,
CthAwkFn  awkfn,
CthThFn  chsfn 
)

Definition at line 648 of file threads.c.

Referenced by CthSchedInit(), CthSetStrategyDefault(), and CthSuspendSchedulingThread().

static void CthBaseResume ( CthThread  t  )  [inline, static]

void CthSwitchThread ( CthThread  t  ) 

switch the thread to t

Definition at line 673 of file threads.c.

References CthBaseResume().

void CthSuspend ( void   ) 

void CthAwaken ( CthThread  th  ) 

void CthYield ( void   ) 

void CthAwakenPrio ( CthThread  th,
int  s,
int  pb,
unsigned int prio 
)

Definition at line 748 of file threads.c.

References CthNoStrategy(), and traceAwaken().

Referenced by CthYieldPrio().

void CthYieldPrio ( int  s,
int  pb,
unsigned int prio 
)

Definition at line 763 of file threads.c.

References CthAwakenPrio(), and CthSuspend().

void CthAddListener ( CthThread  th,
struct CthThreadListener l 
)

This listener is about to begin receiving suspend and resume events for this thread.

"suspend", "resume", "free", and "data" fields must all already be set. When this thread exits, l->free will be called on this listener, which should deallocate the listener memory.

Definition at line 772 of file threads.c.

References CthThreadListener::next, p, and CthThreadListener::thread.

Referenced by CkMigratable::CkAddThreadListeners(), and TraceProjections::traceAddThreadListeners().

int CthMigratable (  ) 

Definition at line 837 of file threads.c.

Referenced by TCharm::migrateTo(), and TCHARM_Migrate().

CthThread CthPup ( pup_er  p,
CthThread  t 
)

Definition at line 842 of file threads.c.

References CmiAbort(), CthFree(), CthPupBase(), malloc(), pup_bytes(), pup_isDeleting(), and pup_isUnpacking().

Referenced by TCharm::pupThread().

CthCpvDeclare ( CthProcInfo  ,
CthProc   
)

static void CthThreadInit ( CthThread  t,
CthVoidFn  fn,
void *  arg 
) [static]

static void CthThreadFree ( CthThread  t  )  [static]

void CthFree ( CthThread  t  ) 

void CthDummy (  ) 

Definition at line 904 of file threads.c.

Referenced by CthInit(), and CthResume1().

void CthInit ( char **  argv  ) 

static void CthOnly ( CthThread  t,
void *  dum1,
void *  dum2 
) [static]

Definition at line 941 of file threads.c.

References CthThreadFinished(), CthThreadStruct::startarg, and CthThreadStruct::startfn.

Referenced by CthResume1().

size_t CthStackOffset ( CthThread  t,
char *  p 
)

Definition at line 950 of file threads.c.

References s, CthThreadStruct::stack, and CthProcInfo::stackbase.

Referenced by TCharm::UserData::UserData().

char* CthPointer ( CthThread  t,
size_t  pos 
)

static void CthResume1 ( qt_t *  sp,
CthProcInfo  proc,
CthThread  t 
) [static]

void CthResume ( CthThread  t  ) 

CthThread CthCreate ( CthVoidFn  fn,
void *  arg,
int  size 
)

CthThread CthCreateMigratable ( CthVoidFn  fn,
void *  arg,
int  size 
)

Definition at line 1027 of file threads.c.

References CthCreate().

Referenced by TCharm::TCharm().

WINBASEAPI LPVOID WINAPI CreateFiber ( DWORD  dwStackSize,
LPFIBER_START_ROUTINE  lpStartAddress,
LPVOID  lpParameter 
)

WINBASEAPI LPVOID WINAPI CreateFiberEx ( SIZE_T  dwStackCommitSize,
SIZE_T  dwStackReserveSize,
DWORD  dwFlags,
LPFIBER_START_ROUTINE  lpStartAddress,
LPVOID  lpParameter 
)

Referenced by CthCreate().

WINBASEAPI VOID WINAPI DeleteFiber ( LPVOID  lpFiber  ) 

WINBASEAPI LPVOID WINAPI ConvertThreadToFiber ( LPVOID  lpParameter  ) 

WINBASEAPI VOID WINAPI SwitchToFiber ( LPVOID  lpFiber  ) 

Referenced by CthFiberBlock(), and CthResume().

WINBASEAPI BOOL WINAPI SwitchToThread ( VOID   ) 

CthCpvStatic ( CthThread  ,
CthPrevious   
)

CthCpvStatic ( int  ,
tablesize   
)

CthCpvStatic ( threadTable  ,
exitThreads   
)

CthCpvStatic ( int  ,
nExit   
)

static void CthThreadInit ( CthThread  t  )  [static]

Definition at line 1120 of file threads.c.

References CthThreadStruct::base, and CthThreadBaseInit().

static void CthClearThreads (  )  [static]

Definition at line 1161 of file threads.c.

References CthThreadFree(), n, and p.

Referenced by CthFree(), and FiberSetUp().

void CthFiberBlock ( CthThread  t  ) 

Definition at line 1220 of file threads.c.

References CthThreadFree(), CthThreadStruct::fiber, and SwitchToFiber().

Referenced by CthResume().

VOID CALLBACK FiberSetUp ( PVOID  fiberData  ) 

Definition at line 1250 of file threads.c.

References CthClearThreads(), CthSelf(), CthThreadFinished(), and ptr.

Referenced by CthCreate().

CthCpvStatic ( pthread_mutex_t  ,
sched_mutex   
)

The sched_mutex is the current token of execution.

Only the running thread holds this lock; all other threads have released the lock and are waiting on their condition variable.

static void* CthOnly ( void *  arg  )  [static]

CpvStaticDeclare ( CthThread  ,
doomedThreadPool   
)

void CthStartThread ( CmiUInt4  fn1,
CmiUInt4  fn2,
CmiUInt4  arg1,
CmiUInt4  arg2 
)

Definition at line 1617 of file threads.c.

References CthSelf(), and CthThreadFinished().

Referenced by CthCreateInner().

void CthStartThread ( qt_userf_t  fn,
void *  arg 
)

Definition at line 1627 of file threads.c.

References CthSelf(), and CthThreadFinished().

int ptrDiffLen ( const void *  a,
const void *  b 
)

Definition at line 1637 of file threads.c.

Referenced by CthCreateInner().

static CthThread CthCreateInner ( CthVoidFn  fn,
void *  arg,
int  size,
int  migratable 
) [static]

static CthThread CthThreadInit ( void   )  [static]

static void* CthAbortHelp ( qt_t *  sp,
CthThread  old,
void *  null 
) [static]

Definition at line 1870 of file threads.c.

References CthThreadFree().

static void* CthBlockHelp ( qt_t *  sp,
CthThread  old,
void *  null 
) [static]

Definition at line 1876 of file threads.c.

References CthThreadStruct::stackp.

static void CthOnly ( void *  arg,
void *  vt,
qt_userf_t  fn 
) [static]

Definition at line 1907 of file threads.c.

References CthSelf(), and CthThreadFinished().

void CthPrintThdStack ( CthThread  t  ) 

void CthTraceResume ( CthThread  t  ) 

void CthPrintThdMagic ( CthThread  t  ) 

Definition at line 2028 of file threads.c.

References CthThreadStruct::base, CmiPrintf(), and CthThreadBase::magic.


Variable Documentation

int CmiThreadIs_flag = 0 [static]

Definition at line 182 of file threads.c.

CthAliasEnable brings this thread's stack into memory.

You must call it before accessing the thread stack, for example, before running, packing, or unpacking the stack data.

Definition at line 268 of file threads.c.


Generated on Sat May 26 08:08:07 2012 for Charm++ by  doxygen 1.5.5