- do\r
- {\r
- /* If xTicksToWait is zero then we are not going to block even\r
- if there is no room in the queue to post. */\r
- if( xTicksToWait > ( portTickType ) 0 )\r
- {\r
- vTaskSuspendAll();\r
- prvLockQueue( pxQueue );\r
-\r
- if( xReturn == pdTRUE )\r
- {\r
- /* This is the first time through - we need to capture the\r
- time while the scheduler is locked to ensure we attempt to\r
- block at least once. */\r
- vTaskSetTimeOutState( &xTimeOut );\r
- }\r
-\r
- if( prvIsQueueFull( pxQueue ) )\r
- {\r
- /* Need to call xTaskCheckForTimeout again as time could\r
- have passed since it was last called if this is not the\r
- first time around this loop. */\r
- if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
- {\r
- traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
- vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
-\r
- /* Unlocking the queue means queue events can effect the\r
- event list. It is possible that interrupts occurring now\r
- remove this task from the event list again - but as the\r
- scheduler is suspended the task will go onto the pending\r
- ready last instead of the actual ready list. */\r
- prvUnlockQueue( pxQueue );\r
-\r
- /* Resuming the scheduler will move tasks from the pending\r
- ready list into the ready list - so it is feasible that this\r
- task is already in a ready list before it yields - in which\r
- case the yield will not cause a context switch unless there\r
- is also a higher priority task in the pending ready list. */\r
- if( !xTaskResumeAll() )\r
- {\r
- taskYIELD();\r
- }\r
- }\r
- else\r
- {\r
- prvUnlockQueue( pxQueue );\r
- ( void ) xTaskResumeAll();\r
- }\r
- }\r
- else\r
- {\r
- /* The queue was not full so we can just unlock the\r
- scheduler and queue again before carrying on. */\r
- prvUnlockQueue( pxQueue );\r
- ( void ) xTaskResumeAll();\r
- }\r
- }\r
-\r
- /* Higher priority tasks and interrupts can execute during\r
- this time and could possible refill the queue - even if we\r
- unblocked because space became available. */\r