![]() |
This is Unofficial EPICS BASE Doxygen Site
|
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <windows.h>
#include <process.h>
#include "epicsStdio.h"
#include "libComAPI.h"
#include "epicsThread.h"
#include "cantProceed.h"
#include "epicsAssert.h"
#include "ellLib.h"
#include "epicsExit.h"
#include "epicsAtomic.h"
Go to the source code of this file.
Classes | |
struct | win32ThreadGlobal |
struct | epicsThreadOSD |
struct | epicsThreadPrivateOSD |
Macros | |
#define | VC_EXTRALEAN |
#define | STRICT |
#define | _WIN32_WINNT 0x400 /* No support for W95 */ |
#define | STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 |
#define | osdOrdinaryPriorityStateCount 5u |
#define | osdRealtimePriorityStateCount 14u |
#define | STACK_SIZE(f) (f * 0x10000 * sizeof(void *)) |
#define | EPICS_THREAD_ONCE_DONE & threadOnceComplete |
Typedefs | |
typedef struct win32ThreadGlobal | win32ThreadGlobal |
typedef struct epicsThreadOSD | win32ThreadParam |
typedef struct epicsThreadPrivateOSD | epicsThreadPrivateOSD |
Functions | |
LIBCOM_API void | osdThreadHooksRun (epicsThreadId id) |
void | setThreadName (DWORD dwThreadID, LPCSTR szThreadName) |
LIBCOM_API void epicsStdCall | epicsThreadExitMain (void) |
LIBCOM_API void | epicsThreadRealtimeLock (void) |
LIBCOM_API epicsThreadBooleanStatus epicsStdCall | epicsThreadLowestPriorityLevelAbove (unsigned int priority, unsigned *pPriorityJustAbove) |
LIBCOM_API epicsThreadBooleanStatus epicsStdCall | epicsThreadHighestPriorityLevelBelow (unsigned int priority, unsigned *pPriorityJustBelow) |
LIBCOM_API unsigned int epicsStdCall | epicsThreadGetStackSize (epicsThreadStackSizeClass stackSizeClass) |
epicsThreadId | epicsThreadCreateOpt (const char *pName, EPICSTHREADFUNC pFunc, void *pParm, const epicsThreadOpts *opts) |
Allocate and start a new OS thread. More... | |
void | epicsThreadMustJoin (epicsThreadId id) |
LIBCOM_API void epicsStdCall | epicsThreadSuspendSelf () |
LIBCOM_API void epicsStdCall | epicsThreadResume (epicsThreadId id) |
LIBCOM_API unsigned epicsStdCall | epicsThreadGetPriority (epicsThreadId id) |
LIBCOM_API unsigned epicsStdCall | epicsThreadGetPrioritySelf () |
LIBCOM_API void epicsStdCall | epicsThreadSetPriority (epicsThreadId id, unsigned priority) |
LIBCOM_API int epicsStdCall | epicsThreadIsEqual (epicsThreadId id1, epicsThreadId id2) |
LIBCOM_API int epicsStdCall | epicsThreadIsSuspended (epicsThreadId id) |
LIBCOM_API void epicsStdCall | epicsThreadSleep (double seconds) |
Block the calling thread for at least the specified time. More... | |
double epicsStdCall | epicsThreadSleepQuantum () |
Query a value approximating the OS timer/scheduler resolution. More... | |
LIBCOM_API epicsThreadId epicsStdCall | epicsThreadGetIdSelf (void) |
LIBCOM_API epicsThreadId epicsStdCall | epicsThreadGetId (const char *pName) |
LIBCOM_API const char *epicsStdCall | epicsThreadGetNameSelf (void) |
LIBCOM_API void epicsStdCall | epicsThreadGetName (epicsThreadId id, char *pName, size_t size) |
LIBCOM_API void | epicsThreadMap (EPICS_THREAD_HOOK_ROUTINE func) |
LIBCOM_API void epicsStdCall | epicsThreadShowAll (unsigned level) |
LIBCOM_API void epicsStdCall | epicsThreadShow (epicsThreadId id, unsigned level) |
LIBCOM_API void epicsStdCall | epicsThreadOnce (epicsThreadOnceId *id, void(*func)(void *), void *arg) |
LIBCOM_API epicsThreadPrivateId epicsStdCall | epicsThreadPrivateCreate () |
LIBCOM_API void epicsStdCall | epicsThreadPrivateDelete (epicsThreadPrivateId p) |
LIBCOM_API void epicsStdCall | epicsThreadPrivateSet (epicsThreadPrivateId pPvt, void *pVal) |
LIBCOM_API void *epicsStdCall | epicsThreadPrivateGet (epicsThreadPrivateId pPvt) |
LIBCOM_API int | epicsThreadGetCPUs (void) |
#define _WIN32_WINNT 0x400 /* No support for W95 */ |
Definition at line 22 of file osdThread.c.
#define EPICS_THREAD_ONCE_DONE & threadOnceComplete |
#define osdOrdinaryPriorityStateCount 5u |
Definition at line 67 of file osdThread.c.
#define osdRealtimePriorityStateCount 14u |
Definition at line 77 of file osdThread.c.
#define STACK_SIZE | ( | f | ) | (f * 0x10000 * sizeof(void *)) |
#define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 |
Definition at line 64 of file osdThread.c.
#define STRICT |
Definition at line 20 of file osdThread.c.
#define VC_EXTRALEAN |
Definition at line 19 of file osdThread.c.
typedef struct epicsThreadPrivateOSD epicsThreadPrivateOSD |
typedef struct win32ThreadGlobal win32ThreadGlobal |
typedef struct epicsThreadOSD win32ThreadParam |
epicsThreadId epicsThreadCreateOpt | ( | const char * | name, |
EPICSTHREADFUNC | funptr, | ||
void * | parm, | ||
const epicsThreadOpts * | opts | ||
) |
Allocate and start a new OS thread.
name | A name describing this thread. Appears in various log and error message. |
funptr | The thread main function. |
parm | Passed to thread main function. |
opts | Modifiers for the new thread, or NULL to use target specific defaults. |
Definition at line 548 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadExitMain | ( | void | ) |
If the main routine is done but wants to let other threads run it can call this routine. This should be the last call in main, except the final return. On most systems epicsThreadExitMain never returns.This must only be called by the main thread.
Definition at line 249 of file osdThread.c.
LIBCOM_API int epicsThreadGetCPUs | ( | void | ) |
Return a value approximating the number of threads which this target can run in parallel. This value is advisory.
Definition at line 1114 of file osdThread.c.
LIBCOM_API epicsThreadId epicsStdCall epicsThreadGetId | ( | const char * | name | ) |
Attempt to find the first instance of a thread by name.
Definition at line 850 of file osdThread.c.
LIBCOM_API epicsThreadId epicsStdCall epicsThreadGetIdSelf | ( | void | ) |
Find an epicsThreadId associated with the current thread. For non-EPICS threads, a new epicsThreadId may be allocated.
Definition at line 834 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadGetName | ( | epicsThreadId | id, |
char * | name, | ||
size_t | size | ||
) |
Copy out the thread name into the provided buffer.
Guaranteed to be null terminated. size is number of bytes in buffer to hold name (including terminator). Failure results in an empty string stored in name.
Definition at line 907 of file osdThread.c.
LIBCOM_API const char* epicsStdCall epicsThreadGetNameSelf | ( | void | ) |
Return the name of the current thread.
This is either a copy of the string passed to epicsThread*Create*(), or an arbitrary unique string for non-EPICS threads.
Definition at line 881 of file osdThread.c.
LIBCOM_API unsigned epicsStdCall epicsThreadGetPriority | ( | epicsThreadId | id | ) |
LIBCOM_API unsigned epicsStdCall epicsThreadGetPrioritySelf | ( | void | ) |
Return thread OSI priority
Definition at line 713 of file osdThread.c.
LIBCOM_API unsigned int epicsStdCall epicsThreadGetStackSize | ( | epicsThreadStackSizeClass | size | ) |
Get a stack size value that can be given to epicsThreadCreate().
size | one of the values epicsThreadStackSmall, epicsThreadStackMedium or epicsThreadStackBig. |
Definition at line 420 of file osdThread.c.
LIBCOM_API epicsThreadBooleanStatus epicsStdCall epicsThreadHighestPriorityLevelBelow | ( | unsigned int | priority, |
unsigned * | pPriorityJustBelow | ||
) |
Lookup the next usage OSI priority such that priority > *pPriorityJustBelow if this is possible with the current target configuration and privlages.
Definition at line 390 of file osdThread.c.
LIBCOM_API int epicsStdCall epicsThreadIsEqual | ( | epicsThreadId | id1, |
epicsThreadId | id2 | ||
) |
Test if two thread IDs actually refer to the same OS thread
Definition at line 749 of file osdThread.c.
LIBCOM_API int epicsStdCall epicsThreadIsSuspended | ( | epicsThreadId | id | ) |
How and why a thread can be suspended is implementation dependent. A thread calling epicsThreadSuspendSelf() should result in this routine returning true for that thread, but a thread may also be suspended for other reasons.
Definition at line 759 of file osdThread.c.
LIBCOM_API epicsThreadBooleanStatus epicsStdCall epicsThreadLowestPriorityLevelAbove | ( | unsigned int | priority, |
unsigned * | pPriorityJustAbove | ||
) |
Lookup the next usage OSI priority such that priority < *pPriorityJustBelow if this is possible with the current target configuration and privlages.
Definition at line 360 of file osdThread.c.
LIBCOM_API void epicsThreadMap | ( | EPICS_THREAD_HOOK_ROUTINE | func | ) |
Call func once for every known thread.
Definition at line 982 of file osdThread.c.
void epicsThreadMustJoin | ( | epicsThreadId | id | ) |
Wait for a joinable thread to exit (return from its main function)
Definition at line 624 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadOnce | ( | epicsThreadOnceId * | id, |
void(*)(void *) | func, | ||
void * | arg | ||
) |
Definition at line 1036 of file osdThread.c.
LIBCOM_API epicsThreadPrivateId epicsStdCall epicsThreadPrivateCreate | ( | void | ) |
Allocate a new thread local variable. This variable will initially hold NULL for each thread.
Definition at line 1071 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadPrivateDelete | ( | epicsThreadPrivateId | id | ) |
LIBCOM_API void* epicsStdCall epicsThreadPrivateGet | ( | epicsThreadPrivateId | ) |
LIBCOM_API void epicsStdCall epicsThreadPrivateSet | ( | epicsThreadPrivateId | , |
void * | |||
) |
LIBCOM_API void epicsThreadRealtimeLock | ( | void | ) |
When real-time scheduling is active, attempt any post-init operations that preserve real-time performance. For POSIX targets this locks the process into RAM, preventing swap-related VM faults.
Definition at line 278 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadResume | ( | epicsThreadId | id | ) |
Resume a thread suspended with epicsThreadSuspendSelf()
Definition at line 683 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadSetPriority | ( | epicsThreadId | id, |
unsigned | priority | ||
) |
Definition at line 739 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadShow | ( | epicsThreadId | id, |
unsigned | level | ||
) |
Definition at line 1027 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadShowAll | ( | unsigned | level | ) |
Definition at line 1004 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadSleep | ( | double | seconds | ) |
Block the calling thread for at least the specified time.
seconds | Time to wait in seconds. Values <=0 blocks for the shortest possible time. |
Definition at line 782 of file osdThread.c.
double epicsStdCall epicsThreadSleepQuantum | ( | void | ) |
Query a value approximating the OS timer/scheduler resolution.
Definition at line 802 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadSuspendSelf | ( | void | ) |
Block the current thread until epicsThreadResume().
Definition at line 658 of file osdThread.c.
LIBCOM_API void osdThreadHooksRun | ( | epicsThreadId | id | ) |
Definition at line 105 of file osdThreadHooks.c.
void setThreadName | ( | DWORD | dwThreadID, |
LPCSTR | szThreadName | ||
) |
Definition at line 26 of file setThreadName.cpp.