#include "nsthread.h"Go to the source code of this file.
Defines | |
| #define | NSTHREAD_EXPORTS |
Functions | |
| int | NsGetStack (void **addrPtr, size_t *sizePtr) |
| void | NsthreadsInit (void) |
| void | NsInitThreads (void) |
| void | NsInitMaster (void) |
| void | NsInitReentrant (void) |
| void | NsMutexInitNext (Ns_Mutex *mutex, char *prefix, unsigned int *nextPtr) |
| void * | NsGetLock (Ns_Mutex *mutex) |
| void * | NsLockAlloc (void) |
| void | NsLockFree (void *lock) |
| void | NsLockSet (void *lock) |
| int | NsLockTry (void *lock) |
| void | NsLockUnset (void *lock) |
| void | NsCleanupTls (void **slots) |
| void ** | NsGetTls (void) |
| void | NsThreadMain (void *arg) |
| void | NsCreateThread (void *arg, long stacksize, Ns_Thread *threadPtr) |
| void | NsThreadFatal (char *func, char *osfunc, int err) _nsnoreturn |
| #define NSTHREAD_EXPORTS |
thread.h --
Private nsthread library include.
| void NsCleanupTls | ( | void ** | slots | ) |
----------------------------------------------------------------------
NsCleanupTls --
Cleanup thread local storage in LIFO order for an exiting thread. Note the careful use of the counters to keep iterating over the list, up to 5 times, until all TLS values are NULL. This emulates the Pthread TLS behavior which catches a destructor inadvertantly calling a library which resets a TLS value after it's been destroyed.
Results: None.
Side effects: Cleanup procs are invoked for non-null values.
----------------------------------------------------------------------
| void NsCreateThread | ( | void * | arg, | |
| long | stacksize, | |||
| Ns_Thread * | resultPtr | |||
| ) |
----------------------------------------------------------------------
NsCreateThread --
WinThread specific thread create function called by Ns_ThreadCreate. Note the use of _beginthreadex. CreateThread does not initialize the C runtime library fully and could lead to memory leaks on thread exit.
Results: None.
Side effects: Depends on thread startup routine.
----------------------------------------------------------------------
Round the stacksize to a pagesize and include the guardzone.
System scope always preferred, ignore any unsupported error.
| void* NsGetLock | ( | Ns_Mutex * | mutex | ) |
----------------------------------------------------------------------
NsGetLock --
Return the private lock pointer for a Ns_Mutex.
Results: Pointer to lock.
Side effects: None.
----------------------------------------------------------------------
| int NsGetStack | ( | void ** | addrPtr, | |
| size_t * | sizePtr | |||
| ) |
----------------------------------------------------------------------
NsGetStack --
Return stack info.
Results: Unsupport, always returns 0.
Side effects: None.
----------------------------------------------------------------------
| void** NsGetTls | ( | void | ) |
----------------------------------------------------------------------
NsGetTls --
Return the TLS slots for this thread.
Results: Pointer to slots array.
Side effects: None.
----------------------------------------------------------------------
| void NsInitMaster | ( | void | ) |
----------------------------------------------------------------------
Ns_MasterLock, Ns_MasterUnlock --
Enter the single master critical section lock.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void NsInitReentrant | ( | void | ) |
| void NsInitThreads | ( | void | ) |
----------------------------------------------------------------------
NsInitThreads --
Core threads init.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void* NsLockAlloc | ( | void | ) |
----------------------------------------------------------------------
NsLockAlloc --
Allocate and initialize a mutex lock.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void NsLockFree | ( | void * | lock | ) |
----------------------------------------------------------------------
NsLockFree --
Free a mutex lock.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void NsLockSet | ( | void * | lock | ) |
----------------------------------------------------------------------
NsLockSet --
Set a mutex lock.
Results: None.
Side effects: May wait wakeup event if lock already held.
----------------------------------------------------------------------
| int NsLockTry | ( | void * | lock | ) |
----------------------------------------------------------------------
NsLockTry --
Try to set a mutex lock once.
Results: 1 if lock set, 0 otherwise.
Side effects: None.
----------------------------------------------------------------------
| void NsLockUnset | ( | void * | lock | ) |
----------------------------------------------------------------------
NsLockUnset --
Unset a mutex lock.
Results: None.
Side effects: May signal wakeup event for a waiting thread.
----------------------------------------------------------------------
NB: It's safe to send the Wakeup() signal after spin unlock because the waiting thread is in an infiniate wait.
| void NsMutexInitNext | ( | Ns_Mutex * | mutex, | |
| char * | prefix, | |||
| unsigned int * | nextPtr | |||
| ) |
----------------------------------------------------------------------
NsMutexInitNext --
Initialize and name the next internal mutex.
Results: None.
Side effects: Given counter is updated.
----------------------------------------------------------------------
| void NsThreadFatal | ( | char * | func, | |
| char * | osfunc, | |||
| int | err | |||
| ) |
----------------------------------------------------------------------
NsThreadFatal --
Call NsThreadAbort when an operating system function fails.
Results: None.
Side effects: Process is aborted through NsThreadAbort.
----------------------------------------------------------------------
| void NsThreadMain | ( | void * | arg | ) |
----------------------------------------------------------------------
ThreadMain --
Thread startup routine. Sets the given pre-allocated thread structure and calls the user specified procedure.
Results: None. Will call Ns_ThreadExit if not called by the user code.
Side effects: None.
----------------------------------------------------------------------
| void NsthreadsInit | ( | void | ) |
1.5.1