11.07.2015 Views

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Resource semaphoresResource semaphores API function overviewRoutineOS_CREATERSEMA()OS_Use()OS_Unuse()OS_Request()OS_GetSemaValue()OS_GetResourceOwner()OS_DeleteRSema()Table 40: Resource semaphore API overviewOS_CREATERSEMA()DescriptionMacro that creates a resource semaphore.Prototypevoid OS_CREATERSEMA (OS_RSEMA* pRSema);ParameterDescriptionpRSemaTable 41: OS_CREATESEMA() parameter listAdditional InformationAfter creation, the resource is not blocked; the value of the counter is 0.OS_Use()DescriptionClaims a resource and blocks it for other tasks.Prototypeint OS_Use (OS_RSEMA* pRSema);ParameterDescriptionpRSemaTable 42: OS_Use() parameter listReturn valueThe counter value of the semaphore.A value larger than 1 means the resource was already locked by the calling task.Additional InformationDescriptionMacro that creates a resource semaphore.Claims a resource and blocks it for other tasks.Releases a semaphore currently in use by a task.Requests a specified semaphore, blocks it for other tasks if it is available. Continuesexecution in any case.Returns the value of the usage counter of a specified resource semaphore.Returns a pointer to the task that is currently using (blocking) a resource.Deletes a specified resource semaphore.Pointer to the data structure for a resource semaphore.Pointer to the data structure for a resource semaphore.The following situations are possible:● Case A: The resource is not in use.If the resource is not used by a task, which means the counter of the semaphore is 0, the resource will be blockedfor other tasks by incrementing the counter and writing a unique code for the task that uses it into the semahore.● Case B: The resource is used by this task.The counter of the semaphore is simply incremented. The program continues without a break.● Case C: The resource is being used by another task.The execution of this task is suspended until the resource semaphore is released. In the meantime if the taskblocked by the resource semaphore has a higher priority than the task blocking the semaphore, the blocking task isassigned the priority of the task requesting the resource semaphore. This is called priority inversion. Priorityinversion can only temporarily increase the priority of a task, never reduce it.PP<strong>RTOS</strong>-251

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!