From: richardbarry Date: Wed, 9 Feb 2011 19:21:58 +0000 (+0000) Subject: Minor updates to the queue.c and tasks.c core files required to support the new timer... X-Git-Tag: V7.0.0~65 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9f24ad3db4897ed7f461969489e793ced09b0d98;p=freertos Minor updates to the queue.c and tasks.c core files required to support the new timers implementation. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1284 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/queue.c b/Source/queue.c index 2107b3637..96552f783 100644 --- a/Source/queue.c +++ b/Source/queue.c @@ -1440,7 +1440,7 @@ signed portBASE_TYPE xReturn; } #endif - /*-----------------------------------------------------------*/ +/*-----------------------------------------------------------*/ #if configQUEUE_REGISTRY_SIZE > 0 @@ -1463,4 +1463,27 @@ signed portBASE_TYPE xReturn; } #endif +/*-----------------------------------------------------------*/ + +#if configUSE_TIMERS == 1 + + void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) + { + /* This function should not be called by application code hence the + 'Restricted' in its name. It is not part of the public API. It is designed + for use by kernel code, and has special calling requirements - it should be + called from a critical section, and then a yield performed after it is + called. Also, the call tree makes use of vListInsert() which should normally + not be called from a critical section - so an assumption is made that the list + being inserted into is empty and therefore the insertion will be fast. */ + + /* Only do anything if there are no message in the queue. */ + if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0U ) + { + /* There is nothing in the queue, block for the specified period. */ + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + } + } + +#endif diff --git a/Source/tasks.c b/Source/tasks.c index 201b0629c..6f305f725 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -63,6 +63,7 @@ task.h is included from an application file. */ #include "FreeRTOS.h" #include "task.h" +#include "timers.h" #include "StackMacros.h" #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE @@ -747,6 +748,19 @@ tskTCB * pxNewTCB; #endif /*-----------------------------------------------------------*/ +void vTaskUnblockTask( xTaskHandle pxTask ) +{ +tskTCB *pxTCB = ( tskTCB * ) pxTask; + + /* This function is not intended to be a public API function and definitely + is not for generic use as it assumes pxTask is not the running task and not + suspended, does not remove the task from any event lists it might be + blocked on, and does not take care of mutual exclusion. */ + vListRemove( &( pxTCB->xGenericListItem ) ); + prvAddTaskToReadyQueue( pxTCB ); +} +/*-----------------------------------------------------------*/ + #if ( INCLUDE_uxTaskPriorityGet == 1 ) unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) @@ -1060,6 +1074,15 @@ portBASE_TYPE xReturn; /* Add the idle task at the lowest priority. */ xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL ); + #if ( configUSE_TIMERS == 1 ) + { + if( xReturn == pdPASS ) + { + xReturn = xTimerCreateTimerTask(); + } + } + #endif + if( xReturn == pdPASS ) { /* Interrupts are turned off here, to ensure a tick does not occur