mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Changes to the FreeRTOS code:
+ Introduced xTaskCreateStatic() to allow tasks to be created without any dynamic memory allocation. + When a task notification is used to unblock a task from an ISR, but the xHigherPriorityTaskWoken parameter is not used, then pend a context switch to occur during the next tick interrupt. Demo application changes: + Updated TaskNotify.c to test the case where a task is unblocked by an ISR, but does not use its xHigherPriorityTaskWoken parameter. + Updated the Win32 MSVC project to test statically allocated tasks being created and deleted. + Introduced StaticAllocation.c standard demo task.
This commit is contained in:
parent
7d6609f8db
commit
ea95020ffd
15 changed files with 839 additions and 115 deletions
|
@ -78,7 +78,8 @@
|
|||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
|
@ -102,6 +103,7 @@
|
|||
#define configUSE_ALTERNATIVE_API 1
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
|
||||
/* Software timer related configuration options. */
|
||||
#define configUSE_TIMERS 1
|
||||
|
|
|
@ -151,6 +151,7 @@
|
|||
<ClCompile Include="..\Common\Minimal\QueueSetPolling.c" />
|
||||
<ClCompile Include="..\Common\Minimal\recmutex.c" />
|
||||
<ClCompile Include="..\Common\Minimal\semtest.c" />
|
||||
<ClCompile Include="..\Common\Minimal\StaticAllocation.c" />
|
||||
<ClCompile Include="..\Common\Minimal\TaskNotify.c" />
|
||||
<ClCompile Include="..\Common\Minimal\timerdemo.c" />
|
||||
<ClCompile Include="main.c">
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
<UniqueIdentifier>{34567deb-d5ab-4a56-8640-0aaec609521a}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Common Demo Tasks">
|
||||
<UniqueIdentifier>{2d4a700c-06e3-4dd2-afbe-ab1be71ebe2a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="FreeRTOS Source\Source\Portable">
|
||||
<UniqueIdentifier>{88f409e6-d396-4ac5-94bd-7a99c914be46}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -32,6 +29,15 @@
|
|||
<Filter Include="Demo App Source\FreeRTOS+Trace Recorder">
|
||||
<UniqueIdentifier>{90b56567-bab6-4d92-b319-b514d378329d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Full_Demo">
|
||||
<UniqueIdentifier>{4ae1665e-a7bb-4c1a-81a3-531d883e6f2d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Full_Demo\Common Demo Tasks">
|
||||
<UniqueIdentifier>{2d4a700c-06e3-4dd2-afbe-ab1be71ebe2a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Blinky_Demo">
|
||||
<UniqueIdentifier>{fb86fa48-ac27-4f87-9215-ce9e1a1a85f9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c">
|
||||
|
@ -50,46 +56,46 @@
|
|||
<Filter>FreeRTOS Source\Source\Portable</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\flop.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\GenQTest.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\integer.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\PollQ.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QPeek.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\semtest.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\BlockQ.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\blocktim.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\timers.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\timerdemo.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\countsem.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\death.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\dynamic.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QueueSet.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Run-time-stats-utils.c">
|
||||
<Filter>Demo App Source</Filter>
|
||||
|
@ -113,16 +119,10 @@
|
|||
<Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QueueOverwrite.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_full.c">
|
||||
<Filter>Demo App Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_blinky.c">
|
||||
<Filter>Demo App Source</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\EventGroupsDemo.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\event_groups.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
|
@ -131,16 +131,25 @@
|
|||
<Filter>FreeRTOS Source\Source\Portable</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\IntSemTest.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\TaskNotify.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QueueSetPolling.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\recmutex.c">
|
||||
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_full.c">
|
||||
<Filter>Demo App Source\Full_Demo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_blinky.c">
|
||||
<Filter>Demo App Source\Blinky_Demo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\StaticAllocation.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -154,6 +154,8 @@ void vApplicationMallocFailedHook( void );
|
|||
void vApplicationIdleHook( void );
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
void vApplicationGetIdleTaskMemory( DummyTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize );
|
||||
void vApplicationGetTimerTaskMemory( DummyTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );
|
||||
|
||||
/*
|
||||
* Writes trace data to a disk file when the trace recording is stopped.
|
||||
|
@ -390,3 +392,37 @@ const HeapRegion_t xHeapRegions[] =
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationGetIdleTaskMemory( DummyTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize )
|
||||
{
|
||||
/* The buffers used by the idle task must be static so they are persistent, and
|
||||
so exist after this function returns. */
|
||||
static DummyTCB_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION is set to 1, so the application has the
|
||||
opportunity to supply the buffers that will be used by the Idle task as its
|
||||
stack and to hold its TCB. If these are set to NULL then the buffers will
|
||||
be allocated dynamically, just as if xTaskCreate() had been called. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
*pusIdleTaskStackSize = configMINIMAL_STACK_SIZE; /* In words. NOT in bytes! */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
DummyTCB_t xTimerTaskTCB;
|
||||
void vApplicationGetTimerTaskMemory( DummyTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize )
|
||||
{
|
||||
/* The buffers used by the Timer/Daemon task must be static so they are
|
||||
persistent, and so exist after this function returns. */
|
||||
//static DummyTCB_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION is set to 1, so the application has the
|
||||
opportunity to supply the buffers that will be used by the Timer/RTOS daemon
|
||||
task as its stack and to hold its TCB. If these are set to NULL then the
|
||||
buffers will be allocated dynamically, just as if xTaskCreate() had been
|
||||
called. */
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
*pusTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; /* In words. NOT in bytes! */
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
* to ensure it gets processor time. Its main function is to check that all the
|
||||
* standard demo tasks are still operational. While no errors have been
|
||||
* discovered the check task will print out "No Errors" along with some system
|
||||
* status information. If an error is discovered in the execution of a task
|
||||
* status information. If an error is discovered in the execution of a task
|
||||
* then the check task will print out an appropriate error message.
|
||||
*
|
||||
*/
|
||||
|
@ -135,6 +135,7 @@
|
|||
#include "IntSemTest.h"
|
||||
#include "TaskNotify.h"
|
||||
#include "QueueSetPolling.h"
|
||||
#include "StaticAllocation.h"
|
||||
|
||||
/* Priorities at which the tasks are created. */
|
||||
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
|
||||
|
@ -214,6 +215,7 @@ int main_full( void )
|
|||
vStartInterruptSemaphoreTasks();
|
||||
vStartQueueSetPollingTask();
|
||||
xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
vStartStaticallyAllocatedTasks();
|
||||
|
||||
#if( configUSE_PREEMPTION != 0 )
|
||||
{
|
||||
|
@ -337,6 +339,10 @@ const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );
|
|||
{
|
||||
pcStatusMessage = "Error: Queue set polling";
|
||||
}
|
||||
else if( xAreStaticAllocationTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Static allocation";
|
||||
}
|
||||
|
||||
/* This is the only task that uses stdout so its ok to call printf()
|
||||
directly. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue