Code Examples.
Code Examples.
The following code block shall create the above depicted sample state machine.
void* pMemory;
ClUint32T taskId;
ClRcT myTaskFunction(
void *);
clUint32 taskPriority;
cosTaskLock();
cosTaskUnlock();
time.tsMicroSecond=10;
ClUint32T memAllocated;
clOsalNumMemoryAllocGet (&memAllocated);
ClUint32T memFreed;
clOsalNumMemoryDeallocedGet (&memFreed);
ClUint8T* pSemName = "SEM_NAME";
ClUint32T value = 1;
void processFunction(void* pStr);
cosProcessSuspend(pid);
cosProcessResume(pid);
ClUint8T* pShmName = "SHM_NAME";
void* pMem;
ClUint32T size = 1000;
clUint16_t mode = 0;
cosCleanUp();
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
ClPtrT clHeapAllocate(CL_IN ClUint32T size)
Allocates memory of the requested size.
ClRcT clOsalProcessSelfIdGet(ClOsalPidT *pProcessId)
Retrieves the processId.
ClRcT clOsalCondCreate(ClOsalCondIdT *pConditionId)
Creates a condition variable.
ClRcT clOsalShmSizeGet(ClOsalShmIdT shmId, ClUint32T *pSize)
Retrieves the size of shared memory.
ClRcT clOsalSemUnlock(ClOsalSemIdT semId)
Unlocks a semaphore.
ClRcT clOsalShmAttach(ClOsalShmIdT shmId, void *pInMem, void **ppOutMem)
Attaches a shared memory.
ClRcT clOsalCondWait(ClOsalCondIdT conditionId, ClOsalMutexIdT mutexId, ClTimerTimeOutT time)
Waits for a condition.
ClRcT clOsalShmSecurityModeSet(ClOsalShmIdT shmId, ClUint32T mode)
Sets permissions to shared memory.
ClRcT clOsalMutexLock(ClOsalMutexIdT mutexId)
Locks a mutex.
ClRcT clOsalTaskDelete(ClOsalTaskIdT taskId)
Deletes a task.
ClRcT clOsalProcessCreate(ClOsalProcessFuncT fpFunction, void *functionArg, ClOsalProcessFlagT creationFlags, ClOsalPidT *pProcessId)
Creates a process.
ClRcT clOsalTaskCreateAttached(const ClCharT *taskName, ClOsalSchedulePolicyT schedulePolicy, ClUint32T priority, ClUint32T stackSize, void *(*fpTaskFunction)(void *), void *pTaskFuncArgument, ClOsalTaskIdT *pTaskId)
Creates a task.
ClRcT clOsalSemCreate(ClUint8T *pName, ClUint32T value, ClOsalSemIdT *pSemId)
Creates a semaphore.
ClRcT clOsalShmDetach(void *pMem)
Detaches a shared memory.
ClRcT clOsalSemLock(ClOsalSemIdT semId)
Locks a semaphore.
ClRcT clOsalTaskDelay(ClTimerTimeOutT timeOut)
Delays a task.
ClUint32T ClOsalShmIdT
The type of an identifier to the OSAL Shared Memory ID.
Definition: clOsalApi.h:243
ClRcT clOsalSelfTaskIdGet(ClOsalTaskIdT *pTaskId)
Retrieves task id.
ClRcT clOsalSemTryLock(ClOsalSemIdT semId)
Locks a semaphore if it is available.
ClRcT clOsalShmDelete(ClOsalShmIdT shmId)
Deletes a shared memory.
ClRcT clOsalMutexCreate(ClOsalMutexIdT *pMutexId)
Creates a mutex.
ClRcT clOsalSemValueGet(ClOsalSemIdT semId, ClUint32T *pSemValue)
Retrieves the value of a semaphore.
ClRcT clOsalProcessDelete(ClOsalPidT processId)
Deletes a process.
ClRcT clOsalMutexDelete(ClOsalMutexIdT mutexId)
Deletes a mutex.
ClRcT clOsalCondBroadcast(ClOsalCondIdT conditionId)
Broadcasts a condition.
ClRcT clOsalCondDelete(ClOsalCondIdT conditionId)
Deletes a condition variable.
ClOsalCondT * ClOsalCondIdT
The type of an identifier to the OSAL condition ID.
Definition: clOsalApi.h:227
ClUint32T ClOsalPidT
The type of an identifier to the OSAL Process ID.
Definition: clOsalApi.h:248
ClRcT clOsalTaskPriorityGet(ClOsalTaskIdT taskId, ClUint32T *pTaskPriority)
Retrieves the priority of the task.
ClRcT clOsalMutexUnlock(ClOsalMutexIdT mutexId)
Unlocks a mutex.
ClRcT clOsalProcessWait(ClOsalPidT processId)
Waits for a process to exit.
ClHandleT ClOsalSemIdT
The type of an identifier to the OSAL Semaphore ID.
Definition: clOsalApi.h:235
ClRcT clOsalTaskCreateDetached(const ClCharT *taskName, ClOsalSchedulePolicyT schedulePolicy, ClUint32T priority, ClUint32T stackSize, void *(*fpTaskFunction)(void *), void *pTaskFuncArgument)
Creates a task.
ClRcT clOsalInitialize(const ClPtrT pConfig)
Initializes the Operating System Abstraction Layer (OSAL).
ClRcT clOsalShmSecurityModeGet(ClOsalShmIdT shmId, ClUint32T *pMode)
Retrieves permissions of shared memory.
ClOsalMutexT * ClOsalMutexIdT
The type of an identifier to the OSAL Mutex ID.
Definition: clOsalApi.h:216
ClRcT clOsalCondSignal(ClOsalCondIdT conditionId)
Signals a condition.
ClRcT clOsalSemDelete(ClOsalSemIdT semId)
Deletes a semaphore.
ClRcT clOsalTaskPrioritySet(ClOsalTaskIdT taskId, ClUint32T taskPriority)
Sets the priority of the task.
ClRcT clOsalShmCreate(ClUint8T *pName, ClUint32T size, ClOsalShmIdT *pShmId)
Creates a shared memory.
@ CL_OSAL_THREAD_PRI_MEDIUM
Medium thread priority.
Definition: clOsalApi.h:309
@ CL_OSAL_SCHED_OTHER
Default scheduling mechanism.
Definition: clOsalApi.h:281
@ CL_OSAL_PROCESS_WITH_NEW_GROUP
This would create a new process group.
Definition: clOsalApi.h:326
The timeout value in seconds and milliseconds.
Definition: clTimerApi.h:87
ClUint32T tsSec
Number of seconds of the timeout.
Definition: clTimerApi.h:89