Go to the source code of this file.
Misc | |
| enum | pte_osResult { PTE_OS_OK = 0, PTE_OS_NO_RESOURCES, PTE_OS_GENERAL_FAILURE, PTE_OS_TIMEOUT, PTE_OS_INTERRUPTED, PTE_OS_INVALID_PARAM } |
| pte_osResult | pte_osInit (void) |
Threads | |
| typedef int(* | pte_osThreadEntryPoint )(void *params) |
| pte_osResult | pte_osThreadCreate (pte_osThreadEntryPoint entryPoint, int stackSize, int initialPriority, void *argv, pte_osThreadHandle *ppte_osThreadHandle) |
| pte_osResult | pte_osThreadStart (pte_osThreadHandle osThreadHandle) |
| void | pte_osThreadExit () |
| pte_osResult | pte_osThreadWaitForEnd (pte_osThreadHandle threadHandle) |
| pte_osThreadHandle | pte_osThreadGetHandle (void) |
| int | pte_osThreadGetPriority (pte_osThreadHandle threadHandle) |
| pte_osResult | pte_osThreadSetPriority (pte_osThreadHandle threadHandle, int newPriority) |
| pte_osResult | pte_osThreadDelete (pte_osThreadHandle handle) |
| pte_osResult | pte_osThreadExitAndDelete (pte_osThreadHandle handle) |
| pte_osResult | pte_osThreadCancel (pte_osThreadHandle threadHandle) |
| pte_osResult | pte_osThreadCheckCancel (pte_osThreadHandle threadHandle) |
| void | pte_osThreadSleep (unsigned int msecs) |
| int | pte_osThreadGetMaxPriority () |
| int | pte_osThreadGetMinPriority () |
| int | pte_osThreadGetDefaultPriority () |
Functions | |
Mutexes | |
| pte_osResult | pte_osMutexCreate (pte_osMutexHandle *pHandle) |
| pte_osResult | pte_osMutexDelete (pte_osMutexHandle handle) |
| pte_osResult | pte_osMutexLock (pte_osMutexHandle handle) |
| pte_osResult | pte_osMutexTimedLock (pte_osMutexHandle handle, unsigned int timeoutMsecs) |
| pte_osResult | pte_osMutexUnlock (pte_osMutexHandle handle) |
Semaphores | |
| pte_osResult | pte_osSemaphoreCreate (int initialValue, pte_osSemaphoreHandle *pHandle) |
| pte_osResult | pte_osSemaphoreDelete (pte_osSemaphoreHandle handle) |
| pte_osResult | pte_osSemaphorePost (pte_osSemaphoreHandle handle, int count) |
| pte_osResult | pte_osSemaphorePend (pte_osSemaphoreHandle handle, unsigned int *pTimeout) |
| pte_osResult | pte_osSemaphoreCancellablePend (pte_osSemaphoreHandle handle, unsigned int *pTimeout) |
Thread Local Storage | |
| pte_osResult | pte_osTlsSetValue (unsigned int key, void *value) |
| void * | pte_osTlsGetValue (unsigned int key) |
| void | pte_osTlsInit (void) |
| pte_osResult | pte_osTlsAlloc (unsigned int *pKey) |
| pte_osResult | pte_osTlsFree (unsigned int key) |
Atomic operations | |
| int | pte_osAtomicExchange (int *pTarg, int val) |
| int | pte_osAtomicCompareExchange (int *pdest, int exchange, int comp) |
| int | pte_osAtomicExchangeAdd (int volatile *pdest, int value) |
| int | pte_osAtomicDecrement (int *pdest) |
| typedef int(* pte_osThreadEntryPoint)(void *params) |
| enum pte_osResult |
| int pte_osAtomicCompareExchange | ( | int * | pdest, | |
| int | exchange, | |||
| int | comp | |||
| ) |
Performs an atomic compare-and-exchange oepration on the specified value. That is:
origVal = *pdest if (*pdest == comp) then *pdest = exchange return origVal
| pdest | Pointer to the destination value. | |
| exchange | Exchange value (value to set destination to if destination == comparand) | |
| comp | The value to compare to destination. |
| int pte_osAtomicDecrement | ( | int * | pdest | ) |
Decrements the destination.
origVal = *pdest
*pdest++
return origVal
| pdest | Destination value to decrement |
| int pte_osAtomicExchange | ( | int * | pTarg, | |
| int | val | |||
| ) |
Sets the target to the specified value as an atomic operation.
origVal = *ptarg
*ptarg = val
return origVal
| pTarg | Pointer to the value to be exchanged. | |
| val | Value to be exchanged |
| int pte_osAtomicExchangeAdd | ( | int volatile * | pdest, | |
| int | value | |||
| ) |
Adds the value to target as an atomic operation
origVal = *pdest
*pAddend += value
return origVal
| pdest | Pointer to the variable to be updated. | |
| value | Value to be added to the variable. |
| pte_osResult pte_osInit | ( | void | ) |
Provides a hook for the OSAL to implement any OS specific initialization. This is guaranteed to be called before any other OSAL function.
| pte_osResult pte_osMutexCreate | ( | pte_osMutexHandle * | pHandle | ) |
Creates a mutex
| pHandle | Set to the handle of the newly created mutex. |
PTE_OS_NO_RESOURCESs - Insufficient resources to create mutex
| pte_osResult pte_osMutexDelete | ( | pte_osMutexHandle | handle | ) |
Deletes a mutex and frees any associated resources.
| handle | Handle of mutex to delete. |
| pte_osResult pte_osMutexLock | ( | pte_osMutexHandle | handle | ) |
Locks the mutex
| handle | Handle of mutex to lock. |
| pte_osResult pte_osMutexTimedLock | ( | pte_osMutexHandle | handle, | |
| unsigned int | timeoutMsecs | |||
| ) |
Locks the mutex, returning after timeoutMsecs if the resources is not available. Can be used for polling mutex by using timeoutMsecs of zero.
| handle | Handle of mutex to lock. | |
| timeoutMsecs | Number of milliseconds to wait for resource before returning. |
PTE_OS_TIMEOUT - Timeout expired before lock was obtained.
| pte_osResult pte_osMutexUnlock | ( | pte_osMutexHandle | handle | ) |
Unlocks the mutex
| handle | Handle of mutex to unlock |
| pte_osResult pte_osSemaphoreCancellablePend | ( | pte_osSemaphoreHandle | handle, | |
| unsigned int * | pTimeout | |||
| ) |
Acquire a semaphore, returning after timeoutMsecs if the semaphore is not available. Can be used for polling a semaphore by using timeoutMsecs of zero. Call must return immediately if pte_osThreadCancel() is called on the thread waiting for the semaphore.
| handle | Handle of semaphore to acquire. | |
| pTimeout | Pointer to the number of milliseconds to wait to acquire the semaphore before returning. If set to NULL, wait forever. |
PTE_OS_TIMEOUT - Timeout expired before semaphore was obtained.
| pte_osResult pte_osSemaphoreCreate | ( | int | initialValue, | |
| pte_osSemaphoreHandle * | pHandle | |||
| ) |
Creates a semaphore
| initialValue | Initial value of the semaphore | |
| pHandle | Set to the handle of the newly created semaphore. |
PTE_OS_NO_RESOURCESs - Insufficient resources to create semaphore
| pte_osResult pte_osSemaphoreDelete | ( | pte_osSemaphoreHandle | handle | ) |
Deletes a semaphore and frees any associated resources.
| handle | Handle of semaphore to delete. |
| pte_osResult pte_osSemaphorePend | ( | pte_osSemaphoreHandle | handle, | |
| unsigned int * | pTimeout | |||
| ) |
Acquire a semaphore, returning after timeoutMsecs if the semaphore is not available. Can be used for polling a semaphore by using timeoutMsecs of zero.
| handle | Handle of semaphore to acquire. | |
| pTimeout | Pointer to the number of milliseconds to wait to acquire the semaphore before returning. If set to NULL, wait forever. |
PTE_OS_TIMEOUT - Timeout expired before semaphore was obtained.
| pte_osResult pte_osSemaphorePost | ( | pte_osSemaphoreHandle | handle, | |
| int | count | |||
| ) |
Posts to the semaphore
| handle | Semaphore to release | |
| count | Amount to increment the semaphore by. |
| pte_osResult pte_osThreadCancel | ( | pte_osThreadHandle | threadHandle | ) |
Cancels the specified thread. This should cause pte_osSemaphoreCancellablePend() and for pte_osThreadCheckCancel() to return PTE_OS_INTERRUPTED.
| threadHandle | handle to the thread to cancel. |
| pte_osResult pte_osThreadCheckCancel | ( | pte_osThreadHandle | threadHandle | ) |
Check if pte_osThreadCancel() has been called on the specified thread.
| threadHandle | handle of thread to check the state of. |
PTE_OS_INTERRUPTED - Thread has been cancelled.
| pte_osResult pte_osThreadCreate | ( | pte_osThreadEntryPoint | entryPoint, | |
| int | stackSize, | |||
| int | initialPriority, | |||
| void * | argv, | |||
| pte_osThreadHandle * | ppte_osThreadHandle | |||
| ) |
Creates a new thread. The thread must be started in a suspended state - it will be explicitly started when pte_osThreadStart() is called.
| entryPoint | Entry point to the new thread. | |
| stackSize | The initial stack size, in bytes. Note that this can be considered a minimum - for instance if the OS requires a larger stack space than what the caller specified. | |
| initialPriority | The priority that the new thread should be initially set to. | |
| argv | Parameter to pass to the new thread. | |
| ppte_osThreadHandle | set to the handle of the new thread. |
PTE_OS_NO_RESOURCESs - Insufficient resources to create thread
| pte_osResult pte_osThreadDelete | ( | pte_osThreadHandle | handle | ) |
Frees resources associated with the specified thread. This is called after the thread has terminated and is no longer needed (e.g. after pthread_join returns). This call will always be made from a different context than that of the target thread.
| void pte_osThreadExit | ( | ) |
Causes the current thread to stop executing.
| pte_osResult pte_osThreadExitAndDelete | ( | pte_osThreadHandle | handle | ) |
Frees resources associated with the specified thread and then causes the thread to exit. This is called after the thread has terminated and is no longer needed (e.g. after pthread_join returns). This call will always be made from the context of the target thread.
| int pte_osThreadGetDefaultPriority | ( | ) |
Returns the priority that should be used if the caller to pthread_create doesn't explicitly set one.
| pte_osThreadHandle pte_osThreadGetHandle | ( | void | ) |
Returns the handle of the currently executing thread.
| int pte_osThreadGetMaxPriority | ( | ) |
Returns the maximum allowable priority
| int pte_osThreadGetMinPriority | ( | ) |
Returns the minimum allowable priority
| int pte_osThreadGetPriority | ( | pte_osThreadHandle | threadHandle | ) |
Returns the priority of the specified thread.
| pte_osResult pte_osThreadSetPriority | ( | pte_osThreadHandle | threadHandle, | |
| int | newPriority | |||
| ) |
Sets the priority of the specified thread.
| void pte_osThreadSleep | ( | unsigned int | msecs | ) |
Causes the current thread to sleep for the specified number of milliseconds.
| pte_osResult pte_osThreadStart | ( | pte_osThreadHandle | osThreadHandle | ) |
Starts executing the specified thread.
| osThreadHandle | handle of the thread to start. |
| pte_osResult pte_osThreadWaitForEnd | ( | pte_osThreadHandle | threadHandle | ) |
Waits for the specified thread to end. If the thread has already terminated, this returns immediately.
| threadHandle | Handle fo thread to wait for. |
| pte_osResult pte_osTlsAlloc | ( | unsigned int * | pKey | ) |
Allocates a new TLS key.
| pKey | On success will be set to the newly allocated key. |
PTE_OS_NO_RESOURCESs - Insufficient resources to allocate key (e.g. maximum number of keys reached).
| pte_osResult pte_osTlsFree | ( | unsigned int | key | ) |
Frees the specified TLS key.
| index | TLS key to free |
| void* pte_osTlsGetValue | ( | unsigned int | key | ) |
Retrieves the thread specific value for the specified key for the currently executing thread. If a value has not been set for this key, NULL should be returned (i.e. TLS values default to NULL).
| index | The TLS key for the value. |
key for the current thread. | void pte_osTlsInit | ( | void | ) |
Initializes the OS TLS support. This is called by the PTE library prior to performing ANY TLS operation.
| pte_osResult pte_osTlsSetValue | ( | unsigned int | key, | |
| void * | value | |||
| ) |
Sets the thread specific value for the specified key for the currently executing thread.
| index | The TLS key for the value. | |
| value | The value to save |
1.5.3