]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/IntSemTest.c
Common scheduler code:
[freertos] / FreeRTOS / Demo / Common / Minimal / IntSemTest.c
index 13ba9bc1420da1463907572ed9fc769be0ce70dc..69a02943cf168349d5ca437153adc5becfee35c2 100644 (file)
@@ -163,7 +163,7 @@ static SemaphoreHandle_t xMasterSlaveMutex = NULL;
 /* Flag that allows the master task to control when the interrupt gives or does\r
 not give the mutex.  There is no mutual exclusion on this variable, but this is\r
 only test code and it should be fine in the 32=bit test environment. */\r
-static BaseType_t xOkToGiveMutex = pdFALSE, xOkToGiveCountingSemaphore = pdFALSE, xOkToGiveMasterSlaveMutex = pdFALSE;\r
+static BaseType_t xOkToGiveMutex = pdFALSE, xOkToGiveCountingSemaphore = pdFALSE;\r
 \r
 /* Used to coordinate timing between tasks and the interrupt. */\r
 const TickType_t xInterruptGivePeriod = pdMS_TO_TICKS( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS );\r
@@ -217,8 +217,6 @@ static void vInterruptMutexMasterTask( void *pvParameters )
 \r
 static void prvTakeAndGiveInTheSameOrder( void )\r
 {\r
-static BaseType_t xGiveFromTask = pdTRUE;\r
-\r
        /* Ensure the slave is suspended, and that this task is running at the\r
        lower priority as expected as the start conditions. */\r
        #if( INCLUDE_eTaskGetState == 1 )\r
@@ -295,27 +293,10 @@ static BaseType_t xGiveFromTask = pdTRUE;
        /* Finally give back the shared mutex.  This time the higher priority\r
        task should run before this task runs again - so this task should have\r
        disinherited the priority and the higher priority task should be in the\r
-       suspended state again.  Alternatve beetween giving the mutex from this task,\r
-       and giving it from the interrupt. */\r
-       if( xGiveFromTask == pdTRUE )\r
-       {\r
-               if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
-\r
-               /* Give the mutex from the interrupt on the next go around. */\r
-               xGiveFromTask = pdFALSE;\r
-       }\r
-       else\r
+       suspended state again. */\r
+       if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS )\r
        {\r
-               /* Wait for the mutex to be given from the interrupt. */\r
-               xOkToGiveMasterSlaveMutex = pdTRUE;\r
-               vTaskDelay( xInterruptGivePeriod + ( xInterruptGivePeriod >> 1 ) );\r
-               xOkToGiveMasterSlaveMutex = pdFALSE;\r
-\r
-               /* Give the mutex from the task on the next go around. */\r
-               xGiveFromTask = pdTRUE;\r
+               xErrorDetected = pdTRUE;\r
        }\r
 \r
        if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY )\r
@@ -533,36 +514,15 @@ TickType_t xTimeNow;
        xTimeNow = xTaskGetTickCountFromISR();\r
        if( ( ( TickType_t ) ( xTimeNow - xLastGiveTime ) ) >= pdMS_TO_TICKS( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS ) )\r
        {\r
+               configASSERT( xISRMutex );\r
                if( xOkToGiveMutex != pdFALSE )\r
                {\r
-                       configASSERT( xISRMutex );\r
-\r
                        /* Null is used as the second parameter in this give, and non-NULL\r
-                       in the other gives, for code coverage reasons.  NOTE:  This is a\r
-                       Mutex, so xQueueGiveFromISR() should be used in place of\r
-                       xSemaphoreGiveFromISR() in case there is a mutex holder that has\r
-                       inherited a priority (although, in the case of xISRMutex, there\r
-                       isn't).  The "item to queue" parameter is set to NULL as no data is \r
-                       copied into a mutex.*/\r
-                       xQueueSendFromISR( ( QueueHandle_t ) xISRMutex, NULL, NULL );\r
-\r
-                       /* Second give attempt should fail. */\r
-                       configASSERT( xQueueSendFromISR( xISRMutex, NULL, &xHigherPriorityTaskWoken ) == pdFAIL );\r
-               }\r
-\r
-               if( xOkToGiveMasterSlaveMutex != pdFALSE )\r
-               {\r
-                       configASSERT( xOkToGiveMasterSlaveMutex );\r
-\r
-                       /* NOTE:  This is a Mutex, so xQueueGiveFromISR() should be used in \r
-                       place of xSemaphoreGiveFromISR() in case there is a mutex holder \r
-                       that has inherited a priority (as indeed there is in this case).  \r
-                       The "item to queue" parameter is set to NULL as no data is copied \r
-                       into a mutex. */\r
-                       xQueueSendFromISR( ( QueueHandle_t ) xMasterSlaveMutex, NULL, NULL );\r
+                       in the other gives for code coverage reasons. */\r
+                       xSemaphoreGiveFromISR( xISRMutex, NULL );\r
 \r
                        /* Second give attempt should fail. */\r
-                       configASSERT( xQueueSendFromISR( xMasterSlaveMutex, NULL, &xHigherPriorityTaskWoken ) == pdFAIL );\r
+                       configASSERT( xSemaphoreGiveFromISR( xISRMutex, &xHigherPriorityTaskWoken ) == pdFAIL );\r
                }\r
 \r
                if( xOkToGiveCountingSemaphore != pdFALSE )\r