3 #include "application.h"
\r
4 #include "internal.h"
\r
11 * Will sleep for sleep ticks. This works only for extended
\r
12 * tasks. If sleep is 0 it will just call the dispatcher to
\r
13 * see if there is anything with higher priority to run.
\r
15 * Sleep(0) only makes sense from a NON task (since they highest
\r
16 * prio task is always running). SetEvent() nor ActivateTask() will
\r
17 * activate a sleeping task.
\r
20 * @return E_OS_ACCESS if called from a basic task
\r
21 * E_OS_RESOURCE called while holding a resource
\r
22 * E_OS_CALLEVEL if called from interrupt context
\r
23 * E_OK if called from a FULL task
\r
26 StatusType Sleep( TickType sleep ) {
\r
27 StatusType rv = E_OK;
\r
28 OsTaskVarType *pcbPtr;
\r
32 pcbPtr = Os_SysTaskGetCurr();
\r
34 if (pcbPtr->constPtr->proc_type != PROC_EXTENDED) {
\r
39 /* Check that we are not calling from interrupt context */
\r
40 if( Os_Sys.intNestCnt != 0 ) {
\r
45 if ( Os_TaskOccupiesResources(pcbPtr) ) {
\r
52 if ( Os_SchedulerResourceIsFree() ) {
\r
54 TAILQ_INSERT_TAIL(&Os_Sys.timerHead,pcbPtr,timerEntry);
\r
55 pcbPtr->timerDec = sleep;
\r
56 Os_Dispatch(OP_SLEEP);
\r
59 if( Os_SysTaskGetCurr()->constPtr->scheduling != NON ) {
\r
63 OsTaskVarType *topTask = Os_TaskGetTop();
\r
64 if( topTask->activePriority != pcbPtr->activePriority ) {
\r
65 Os_Dispatch(OP_SCHEDULE);
\r
72 OS_STD_END_1(OSServiceId_Sleep,sleep);
\r