![]() |
This is Unofficial EPICS BASE Doxygen Site
|
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <pthread.h>
#include <signal.h>
#include <sched.h>
#include <unistd.h>
#include "epicsStdio.h"
#include "ellLib.h"
#include "epicsEvent.h"
#include "epicsMutex.h"
#include "epicsString.h"
#include "epicsThread.h"
#include "cantProceed.h"
#include "errlog.h"
#include "epicsAssert.h"
#include "epicsExit.h"
#include "epicsAtomic.h"
Go to the source code of this file.
Classes | |
struct | commonAttr |
Macros | |
#define | checkStatus(status, message) |
#define | checkStatusQuit(status, message, method) |
#define | checkStatusOnce(status, message) |
#define | checkStatusOnceQuit(status, message, method) |
#define | STACK_SIZE(f) (0) |
#define | EPICS_THREAD_ONCE_DONE &threadOnceComplete |
Typedefs | |
typedef struct commonAttr | commonAttr |
Functions | |
LIBCOM_API void | epicsThreadShowInfo (epicsThreadOSD *pthreadInfo, unsigned int level) |
LIBCOM_API void | osdThreadHooksRun (epicsThreadId id) |
LIBCOM_API void | osdThreadHooksRunMain (epicsThreadId id) |
LIBCOM_API int | epicsThreadGetPosixPriority (epicsThreadId pthreadInfo) |
LIBCOM_API void | epicsThreadRealtimeLock (void) |
LIBCOM_API unsigned int epicsStdCall | epicsThreadGetStackSize (epicsThreadStackSizeClass stackSizeClass) |
LIBCOM_API void epicsStdCall | epicsThreadOnce (epicsThreadOnceId *id, void(*func)(void *), void *arg) |
epicsThreadId | epicsThreadCreateOpt (const char *name, EPICSTHREADFUNC funptr, void *parm, const epicsThreadOpts *opts) |
Allocate and start a new OS thread. More... | |
void | epicsThreadMustJoin (epicsThreadId id) |
LIBCOM_API void epicsStdCall | epicsThreadSuspendSelf (void) |
LIBCOM_API void epicsStdCall | epicsThreadResume (epicsThreadOSD *pthreadInfo) |
LIBCOM_API void epicsStdCall | epicsThreadExitMain (void) |
LIBCOM_API unsigned int epicsStdCall | epicsThreadGetPriority (epicsThreadId pthreadInfo) |
LIBCOM_API unsigned int epicsStdCall | epicsThreadGetPrioritySelf (void) |
LIBCOM_API void epicsStdCall | epicsThreadSetPriority (epicsThreadId pthreadInfo, unsigned int priority) |
LIBCOM_API epicsThreadBooleanStatus epicsStdCall | epicsThreadHighestPriorityLevelBelow (unsigned int priority, unsigned *pPriorityJustBelow) |
LIBCOM_API epicsThreadBooleanStatus epicsStdCall | epicsThreadLowestPriorityLevelAbove (unsigned int priority, unsigned *pPriorityJustAbove) |
LIBCOM_API int epicsStdCall | epicsThreadIsEqual (epicsThreadId p1, epicsThreadId p2) |
LIBCOM_API int epicsStdCall | epicsThreadIsSuspended (epicsThreadId pthreadInfo) |
LIBCOM_API void epicsStdCall | epicsThreadSleep (double seconds) |
Block the calling thread for at least the specified time. More... | |
LIBCOM_API epicsThreadId epicsStdCall | epicsThreadGetIdSelf (void) |
LIBCOM_API pthread_t | epicsThreadGetPosixThreadId (epicsThreadId threadId) |
LIBCOM_API epicsThreadId epicsStdCall | epicsThreadGetId (const char *name) |
LIBCOM_API const char epicsStdCall * | epicsThreadGetNameSelf () |
LIBCOM_API void epicsStdCall | epicsThreadGetName (epicsThreadId pthreadInfo, char *name, size_t size) |
LIBCOM_API void | epicsThreadMap (EPICS_THREAD_HOOK_ROUTINE func) |
LIBCOM_API void epicsStdCall | epicsThreadShowAll (unsigned int level) |
LIBCOM_API void epicsStdCall | epicsThreadShow (epicsThreadId showThread, unsigned int level) |
LIBCOM_API epicsThreadPrivateId epicsStdCall | epicsThreadPrivateCreate (void) |
LIBCOM_API void epicsStdCall | epicsThreadPrivateDelete (epicsThreadPrivateId id) |
LIBCOM_API void epicsStdCall | epicsThreadPrivateSet (epicsThreadPrivateId id, void *value) |
LIBCOM_API void epicsStdCall * | epicsThreadPrivateGet (epicsThreadPrivateId id) |
LIBCOM_API double epicsStdCall | epicsThreadSleepQuantum () |
Query a value approximating the OS timer/scheduler resolution. More... | |
LIBCOM_API int | epicsThreadGetCPUs (void) |
#define checkStatus | ( | status, | |
message | |||
) |
Definition at line 87 of file osdThread.c.
#define checkStatusOnce | ( | status, | |
message | |||
) |
Definition at line 102 of file osdThread.c.
#define checkStatusOnceQuit | ( | status, | |
message, | |||
method | |||
) |
Definition at line 106 of file osdThread.c.
#define checkStatusQuit | ( | status, | |
message, | |||
method | |||
) |
Definition at line 92 of file osdThread.c.
#define EPICS_THREAD_ONCE_DONE &threadOnceComplete |
#define STACK_SIZE | ( | f | ) | (0) |
Definition at line 463 of file osdThread.c.
typedef struct commonAttr commonAttr |
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 529 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 683 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 990 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 826 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 810 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 857 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 846 of file osdThread.c.
LIBCOM_API int epicsThreadGetPosixPriority | ( | epicsThreadId | pthreadInfo | ) |
Definition at line 115 of file osdThread.c.
LIBCOM_API pthread_t epicsThreadGetPosixThreadId | ( | epicsThreadId | threadId | ) |
Definition at line 821 of file osdThread.c.
LIBCOM_API unsigned int epicsStdCall epicsThreadGetPriority | ( | epicsThreadId | id | ) |
LIBCOM_API unsigned int epicsStdCall epicsThreadGetPrioritySelf | ( | void | ) |
Return thread OSI priority
Definition at line 707 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 466 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 740 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 776 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 784 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 757 of file osdThread.c.
LIBCOM_API void epicsThreadMap | ( | EPICS_THREAD_HOOK_ROUTINE | func | ) |
Call func once for every known thread.
Definition at line 864 of file osdThread.c.
void epicsThreadMustJoin | ( | epicsThreadId | id | ) |
Wait for a joinable thread to exit (return from its main function)
Definition at line 632 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadOnce | ( | epicsThreadOnceId * | id, |
void(*)(void *) | func, | ||
void * | arg | ||
) |
Definition at line 487 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 934 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 425 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadResume | ( | epicsThreadOSD * | pthreadInfo | ) |
Definition at line 676 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadSetPriority | ( | epicsThreadId | id, |
unsigned int | priority | ||
) |
Change OSI priority of target thread.
Definition at line 713 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadShow | ( | epicsThreadId | id, |
unsigned int | level | ||
) |
Print info about a single EPICS thread.
Definition at line 903 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadShowAll | ( | unsigned int | level | ) |
Print to stdout information about all running EPICS threads.
level | 0 prints minimal output. Higher values print more details. |
Definition at line 883 of file osdThread.c.
LIBCOM_API void epicsThreadShowInfo | ( | epicsThreadOSD * | pthreadInfo, |
unsigned int | level | ||
) |
Definition at line 22 of file osdThreadExtra.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 790 of file osdThread.c.
LIBCOM_API double epicsStdCall epicsThreadSleepQuantum | ( | void | ) |
Query a value approximating the OS timer/scheduler resolution.
Definition at line 981 of file osdThread.c.
LIBCOM_API void epicsStdCall epicsThreadSuspendSelf | ( | void | ) |
Block the current thread until epicsThreadResume().
Definition at line 664 of file osdThread.c.
LIBCOM_API void osdThreadHooksRun | ( | epicsThreadId | id | ) |
Definition at line 105 of file osdThreadHooks.c.
LIBCOM_API void osdThreadHooksRunMain | ( | epicsThreadId | id | ) |
Definition at line 99 of file osdThreadHooks.c.