From 152260c267c1142862af6ec262159983709c20ea Mon Sep 17 00:00:00 2001 From: richardbarry Date: Wed, 5 Sep 2012 14:02:16 +0000 Subject: [PATCH] Allow mutex type semaphores to be given from an interrupt (not a normal thing to do - use a binary semaphore!). Allow FreeRTOS+CLI commands to have spaces at the end without it being taken as a parameter. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1778 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../FreeRTOS-Plus-CLI/FreeRTOS_CLI.c | 7 ++- FreeRTOS/Source/queue.c | 2 + FreeRTOS/Source/tasks.c | 43 ++++++++++--------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/FreeRTOS-Plus/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c b/FreeRTOS-Plus/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c index 05737f03e..13f584d72 100644 --- a/FreeRTOS-Plus/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c +++ b/FreeRTOS-Plus/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c @@ -152,7 +152,7 @@ size_t xCommandStringLength; pcRegisteredCommandString = pxCommand->pxCommandLineDefinition->pcCommand; xCommandStringLength = strlen( ( const char * ) pcRegisteredCommandString ); - /* To ensure the string lengths match exactly, so as not to pick up + /* To ensure the string lengths match exactly, so as not to pick up a sub-string of a longer command, check the byte after the expected end of the string is either the end of the string or a space before a parameter. */ @@ -253,6 +253,11 @@ const int8_t *pcReturn = NULL; pcCommandString++; } + if( *pxParameterStringLength == 0 ) + { + pcReturn = NULL; + } + break; } } diff --git a/FreeRTOS/Source/queue.c b/FreeRTOS/Source/queue.c index 4748860db..090028d32 100644 --- a/FreeRTOS/Source/queue.c +++ b/FreeRTOS/Source/queue.c @@ -874,7 +874,9 @@ xTimeOutType xTimeOut; if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) { portENTER_CRITICAL(); + { vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); + } portEXIT_CRITICAL(); } } diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index 0c43e63d6..cb123c528 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -2382,30 +2382,33 @@ tskTCB *pxNewTCB; { tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder; - configASSERT( pxMutexHolder ); - - if( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) + /* If the mutex was given back by an interrupt while the queue was + locked then the mutex holder might now be NULL. */ + if( pxMutexHolder != NULL ) { - /* Adjust the mutex holder state to account for its new priority. */ - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority ); - - /* If the task being modified is in the ready state it will need to - be moved in to a new list. */ - if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) + if( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) { - vListRemove( &( pxTCB->xGenericListItem ) ); + /* Adjust the mutex holder state to account for its new priority. */ + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority ); - /* Inherit the priority before being moved into the new list. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - prvAddTaskToReadyQueue( pxTCB ); - } - else - { - /* Just inherit the priority. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - } + /* If the task being modified is in the ready state it will need to + be moved in to a new list. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) + { + vListRemove( &( pxTCB->xGenericListItem ) ); - traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority ); + /* Inherit the priority before being moved into the new list. */ + pxTCB->uxPriority = pxCurrentTCB->uxPriority; + prvAddTaskToReadyQueue( pxTCB ); + } + else + { + /* Just inherit the priority. */ + pxTCB->uxPriority = pxCurrentTCB->uxPriority; + } + + traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority ); + } } } -- 2.39.5