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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Task routinesAdditional InformationThe specified task's suspend count is decremented. If the resulting value is 0, the execution of the specified task isresumed.If the task is not blocked by other task blocking mechanisms, the task will be set back in ready state and continuesoperation according to the rules of the scheduler.In debug versions of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong>, the OS_Resume() function checks the suspend count of the specified task.If the suspend count is 0 when OS_Resume() is called, the specified task is not currently suspended and OS_Error()is called with error OS_ERR_RESUME_BEFORE_SUSPEND.OS_GetSuspendCnt()DescriptionThe function returns the suspension count and thus suspension state of the specified task. This function may be usedfor examining whether a task is suspended by previous calls of OS_Suspend().Prototypeunsigned char OS_GetSuspendCnt (OS_TASK* pTask);ParameterDescriptionpTaskPointer to a data structure of type OS_TASK.Table 15: OS_GetSuspendCnt() parameter listReturn valueSuspension count of the specified task as unsigned character value.0: Task is not suspended.>0: Task is suspended by at least one call of OS_Suspend().Additional InformationIf pTask does not specify a valid task, the debug version of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> calls OS_Error(). The releaseversion of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> can not check the validity of pTask and may therefore return invalid values ifpTask does not specify a valid task. When tasks are created and terminated dynamically, OS_IsTask() may be calledprior calling OS_GetSuspendCnt() to examine whether the task is valid. The remturned value can be used for resuminga suspended task by calling OS_Resume() as often as indicated by the returned value.Example/* Demo-function to illustrate the use of OS_GetSuspendCnt() */void ResumeTask(OS_TASK* pTask) {unsigned char SuspendCnt;SuspendCnt = OS_GetSuspendCnt(pTask);while(SuspendCnt > 0) {OS_Resume(pTask); /* May cause a task switch */SuspendCnt--;}}OS_Terminate()DescriptionEnds (terminates) a task.Prototypevoid OS_Terminate (OS_TASK* pTask);ParameterDescriptionpTaskPointer to a data structure of type OS_TASK which is used as task control block (and reference)for this task.Table 16: OS_Terminate() parameter listAdditional InformationIf pTask is the NULL pointer, the current task terminates. The specified task will terminate immediately. The memoryused for stack and task control block can be reassigned.PP<strong>RTOS</strong>-233

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

Saved successfully!

Ooh no, something went wrong!