]> git.sur5r.net Git - freertos/commitdiff
Implement xTaskResumeFromISR.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 11 Aug 2006 10:02:38 +0000 (10:02 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 11 Aug 2006 10:02:38 +0000 (10:02 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@22 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/include/task.h
Source/tasks.c

index c53864a4651d1d94bd761b59cde7cbab5d9495e1..74f44b6c766801f29ca6aae0b8cfcbfc869040b9 100644 (file)
@@ -533,6 +533,26 @@ void vTaskSuspend( xTaskHandle pxTaskToSuspend );
  */\r
 void vTaskResume( xTaskHandle pxTaskToResume );\r
 \r
+/**\r
+ * task. h\r
+ * <pre>void xTaskResumeFromISR( xTaskHandle pxTaskToResume );</pre>\r
+ *\r
+ * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be \r
+ * available.  See the configuration section for more information.\r
+ *\r
+ * An implementation of vTaskResume() that can be called from within an ISR.\r
+ *\r
+ * A task that has been suspended by one of more calls to vTaskSuspend ()\r
+ * will be made available for running again by a single call to\r
+ * xTaskResumeFromISR ().\r
+ *\r
+ * @param pxTaskToResume Handle to the task being readied.\r
+ *\r
+ * \defgroup vTaskResumeFromISR vTaskResumeFromISR\r
+ * \ingroup TaskCtrl\r
+ */\r
+portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );\r
+\r
 /*-----------------------------------------------------------\r
  * SCHEDULER CONTROL\r
  *----------------------------------------------------------*/\r
index 7f60f8deae8ec557f8b9cedfaf5394d4cf41c108..0e4b1a151fafa831f06da198cda1c0a27869d7f8 100644 (file)
@@ -175,6 +175,7 @@ Changed from V4.0.4
        + vTaskPrioritySet() and vTaskResume() no longer use the event list item.\r
          This has not been necessary since V4.0.1 when the xMissedYield handling\r
          was added.\r
+       + Implement xTaskResumeFromISR().\r
 */\r
 \r
 #include <stdio.h>\r
@@ -211,6 +212,9 @@ Changed from V4.0.4
        #define configMAX_TASK_NAME_LEN 1\r
 #endif\r
 \r
+#ifndef INCLUDE_xTaskResumeFromISR\r
+       #define INCLUDE_xTaskResumeFromISR 1\r
+#endif \r
 \r
 /*\r
  * Task control block.  A task control block (TCB) is allocated to each task,\r
@@ -931,17 +935,21 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
                                /* Is the task we are attempting to resume actually suspended? */\r
                                if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
                                {\r
-                                       /* As we are in a critical section we can access the ready \r
-                                       lists even if the scheduler is suspended. */\r
-                                       vListRemove(  &( pxTCB->xGenericListItem ) );\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
-\r
-                                       /* We may have just resumed a higher priority task. */\r
-                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
-                                       {\r
-                                               /* This yield may not cause the task just resumed to run, but\r
-                                               will leave the lists in the correct state for the next yield. */\r
-                                               taskYIELD();\r
+                                       /* Has the task already been resumed from within an ISR? */\r
+                                       if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) != pdTRUE )\r
+                                       {                       \r
+                                               /* As we are in a critical section we can access the ready \r
+                                               lists even if the scheduler is suspended. */\r
+                                               vListRemove(  &( pxTCB->xGenericListItem ) );\r
+                                               prvAddTaskToReadyQueue( pxTCB );\r
+\r
+                                               /* We may have just resumed a higher priority task. */\r
+                                               if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+                                               {\r
+                                                       /* This yield may not cause the task just resumed to run, but\r
+                                                       will leave the lists in the correct state for the next yield. */\r
+                                                       taskYIELD();\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
@@ -953,34 +961,36 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
 \r
 /*-----------------------------------------------------------*/\r
 \r
-#if ( INCLUDE_vTaskResumeFromISR == 1 )\r
+#if ( INCLUDE_xTaskResumeFromISR == 1 )\r
 \r
        portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume )\r
        {\r
-       portBASE_TYPE xYieldRequired;\r
+       portBASE_TYPE xYieldRequired = pdFALSE;\r
+       tskTCB *pxTCB;\r
+\r
+               pxTCB = ( tskTCB * ) pxTaskToResume;\r
 \r
                /* Is the task we are attempting to resume actually suspended? */\r
-               if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTaskToResume->xGenericListItem ) ) != pdFALSE )\r
+               if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
                {\r
-                       if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
-                       {\r
-                               xYieldRequired = ( pxTaskToResume->uxPriority >= pxCurrentTCB->uxPriority );\r
-                               vListRemove(  &( pxTaskToResume->xGenericListItem ) );\r
-                               prvAddTaskToReadyQueue( pxTaskToResume );\r
-                       }\r
-                       else\r
+                       /* Has the task already been resumed from within an ISR? */\r
+                       if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) != pdTRUE )\r
                        {\r
-                               /* We cannot access the delayed or ready lists, so will hold this\r
-                               task pending until the scheduler is resumed, at which point a \r
-                               yield will be preformed if necessary. */\r
-                               xYieldRequired = pdFALSE;\r
-                               vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxTaskToResume->xEventListItem ) );\r
+                               if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
+                               {\r
+                                       xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );\r
+                                       vListRemove(  &( pxTCB->xGenericListItem ) );   \r
+                                       prvAddTaskToReadyQueue( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* We cannot access the delayed or ready lists, so will hold this\r
+                                       task pending until the scheduler is resumed, at which point a \r
+                                       yield will be preformed if necessary. */\r
+                                       vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
+                               }\r
                        }\r
                }\r
-               else\r
-               {\r
-                       xYieldRequired = pdFALSE;\r
-               }\r
 \r
                return xYieldRequired;\r
        }\r