Skip to content

Commit

Permalink
Feature/multiple direct to task notifications (FreeRTOS#73)
Browse files Browse the repository at this point in the history
* Add TaskNotifyArray.c with the single task tests updated to use the task notification array up to the point where the timer is created.

* Continue working on TaskNotifyArray.c to test the new task notification indexes.  Next TaskNotifyArray.c will be refactored to break the tests up a bit.

* Refactor and update the comments in TaskNotifyArray.c - no functional changes.

* Change from the task notify "array" to task notification "indexed" nomenclature in the new task notification API functions that work on one particular task notification with the array of task notifications.

* Update the implementation of the taskNOTIFY_TAKE() and taskNOTIFY_WAIT() trace macros to take the array index of the task notification they are acting on.
Rename configNUMBER_OF_TASK_NOTIFICATIONS to configTASK_NOTIFICATION_ARRAY_ENTRIES.
Add FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c to the Visual Studio project - the file implements tests specific to the behaviour of the indexed task notification functions and should be used in addition to the tests already provided in FreeRTOS/Demo/Common/Minimal/TaskNotify.c.
  • Loading branch information
RichardBarry authored Jun 8, 2020
1 parent b9e4ecf commit 2df5eee
Show file tree
Hide file tree
Showing 9 changed files with 1,288 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,8 @@ extern void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t si
trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait); \
}
#else /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */
#define traceTASK_NOTIFY_TAKE() \
if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED){ \
#define traceTASK_NOTIFY_TAKE( index ) \
if (pxCurrentTCB->ucNotifyState[ ( index ) ] == taskNOTIFICATION_RECEIVED){ \
trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \
}else{ \
trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait);}
Expand All @@ -1276,10 +1276,10 @@ extern void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t si
prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
}
#else /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */
#define traceTASK_NOTIFY_WAIT() \
#define traceTASK_NOTIFY_WAIT( index ) \
if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \
{ \
if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \
if (pxCurrentTCB->ucNotifyState[ ( index ) ] == taskNOTIFICATION_RECEIVED) \
prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
else \
prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
Expand Down
1,234 changes: 1,234 additions & 0 deletions FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions FreeRTOS/Demo/Common/include/TaskNotifyArray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* FreeRTOS Kernel V10.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/

#ifndef TASK_NOTIFY_ARRAY_H
#define TASK_NOTIFY_ARRAY_H

void vStartTaskNotifyArrayTask( void );
BaseType_t xAreTaskNotificationArrayTasksStillRunning( void );
void xNotifyArrayTaskFromISR( void );

#endif /* TASK_NOTIFY_ARRAY_H */



1 change: 1 addition & 0 deletions FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#define configUSE_ALTERNATIVE_API 0
#define configUSE_QUEUE_SETS 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 5
#define configSUPPORT_STATIC_ALLOCATION 1
#define configINITIAL_TICK_COUNT ( ( TickType_t ) 0 ) /* For test. */
#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 1 /* As there are a lot of tasks running. */
Expand Down
1 change: 1 addition & 0 deletions FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<ClCompile Include="..\Common\Minimal\StreamBufferDemo.c" />
<ClCompile Include="..\Common\Minimal\StreamBufferInterrupt.c" />
<ClCompile Include="..\Common\Minimal\TaskNotify.c" />
<ClCompile Include="..\Common\Minimal\TaskNotifyArray.c" />
<ClCompile Include="..\Common\Minimal\timerdemo.c" />
<ClCompile Include="main.c">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand Down
3 changes: 3 additions & 0 deletions FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@
<ClCompile Include="..\Common\Minimal\MessageBufferAMP.c">
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\TaskNotifyArray.c">
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="FreeRTOSConfig.h">
Expand Down
1 change: 0 additions & 1 deletion FreeRTOS/Demo/WIN32-MSVC/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* port for further information:
* http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html
*
*
*******************************************************************************
*/
Expand Down
7 changes: 7 additions & 0 deletions FreeRTOS/Demo/WIN32-MSVC/main_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#include "EventGroupsDemo.h"
#include "IntSemTest.h"
#include "TaskNotify.h"
#include "TaskNotifyArray.h"
#include "QueueSetPolling.h"
#include "StaticAllocation.h"
#include "blocktim.h"
Expand Down Expand Up @@ -183,6 +184,7 @@ int main_full( void )

/* Create the standard demo tasks. */
vStartTaskNotifyTask();
vStartTaskNotifyArrayTask();
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
Expand Down Expand Up @@ -286,6 +288,10 @@ HeapStats_t xHeapStats;
{
pcStatusMessage = "Error: Notification";
}
else if( xAreTaskNotificationArrayTasksStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: NotificationArray";
}
else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: IntSem";
Expand Down Expand Up @@ -496,6 +502,7 @@ TaskHandle_t xTimerTask;

/* Exercise using task notifications from an interrupt. */
xNotifyTaskFromISR();
xNotifyArrayTaskFromISR();

/* Writes to stream buffer byte by byte to test the stream buffer trigger
level functionality. */
Expand Down
1 change: 0 additions & 1 deletion FreeRTOS/Demo/WIN32-MingW/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ const HeapRegion_t xHeapRegions[] =

/* The heap has not been initialised yet so expect stats to all be zero. */
vPortGetHeapStats( &xHeapStats );
configASSERT( memcmp( &xHeapStats, &xZeroHeapStats, sizeof( HeapStats_t ) ) == 0 );

vPortDefineHeapRegions( xHeapRegions );

Expand Down

0 comments on commit 2df5eee

Please sign in to comment.