Updated the Win32 MSVC demo files.

pull/1/head
Richard Barry 14 years ago
parent 37b6fb5773
commit abadea4557

@ -0,0 +1,398 @@
/*
FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd.
***************************************************************************
* *
* If you are: *
* *
* + New to FreeRTOS, *
* + Wanting to learn FreeRTOS or multitasking in general quickly *
* + Looking for basic training, *
* + Wanting to improve your FreeRTOS skills and productivity *
* *
* then take a look at the FreeRTOS books - available as PDF or paperback *
* *
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
* http://www.FreeRTOS.org/Documentation *
* *
* A pdf reference manual is also available. Both are usually delivered *
* to your inbox within 20 minutes to two hours when purchased between 8am *
* and 8pm GMT (although please allow up to 24 hours in case of *
* exceptional circumstances). Thank you for your support! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
***NOTE*** The exception to the GPL is included to allow you to distribute
a combined work that includes FreeRTOS without being obliged to provide the
source code for proprietary components outside of the FreeRTOS kernel.
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details. You should have received a copy of the GNU General Public
License and the FreeRTOS license exception along with FreeRTOS; if not it
can be viewed here: http://www.freertos.org/a00114.html and also obtained
by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site.
1 tab == 4 spaces!
http://www.FreeRTOS.org - Documentation, latest information, license and
contact details.
http://www.SafeRTOS.com - A version that is certified for use in safety
critical systems.
http://www.OpenRTOS.com - Commercial support, development, porting,
licensing and training services.
*/
/*
The tasks defined on this page demonstrate the use of recursive mutexes.
For recursive mutex functionality the created mutex should be created using
xSemaphoreCreateRecursiveMutex(), then be manipulated
using the xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() API
functions.
This demo creates three tasks all of which access the same recursive mutex:
prvRecursiveMutexControllingTask() has the highest priority so executes
first and grabs the mutex. It then performs some recursive accesses -
between each of which it sleeps for a short period to let the lower
priority tasks execute. When it has completed its demo functionality
it gives the mutex back before suspending itself.
prvRecursiveMutexBlockingTask() attempts to access the mutex by performing
a blocking 'take'. The blocking task has a lower priority than the
controlling task so by the time it executes the mutex has already been
taken by the controlling task, causing the blocking task to block. It
does not unblock until the controlling task has given the mutex back,
and it does not actually run until the controlling task has suspended
itself (due to the relative priorities). When it eventually does obtain
the mutex all it does is give the mutex back prior to also suspending
itself. At this point both the controlling task and the blocking task are
suspended.
prvRecursiveMutexPollingTask() runs at the idle priority. It spins round
a tight loop attempting to obtain the mutex with a non-blocking call. As
the lowest priority task it will not successfully obtain the mutex until
both the controlling and blocking tasks are suspended. Once it eventually
does obtain the mutex it first unsuspends both the controlling task and
blocking task prior to giving the mutex back - resulting in the polling
task temporarily inheriting the controlling tasks priority.
*/
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* Demo app include files. */
#include "recmutex.h"
/* Priorities assigned to the three tasks. */
#define recmuCONTROLLING_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define recmuBLOCKING_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define recmuPOLLING_TASK_PRIORITY ( tskIDLE_PRIORITY + 0 )
/* In this version the tick period is very long, so the short delay cannot be
for too many ticks, or the check task will execute and find that the recmutex
tasks have not completed their functionality and then signal an error. The
delay does however have to be long enough to allow the lower priority tasks
a chance of executing - this is basically achieved by reducing the number
of times the loop that takes/gives the recursive mutex executes. */
#define recmuMAX_COUNT ( 2 )
#define recmuSHORT_DELAY ( 20 )
#define recmuNO_DELAY ( ( portTickType ) 0 )
#define recmuFIVE_TICK_DELAY ( ( portTickType ) 5 )
/* The three tasks as described at the top of this file. */
static void prvRecursiveMutexControllingTask( void *pvParameters );
static void prvRecursiveMutexBlockingTask( void *pvParameters );
static void prvRecursiveMutexPollingTask( void *pvParameters );
/* The mutex used by the demo. */
static xSemaphoreHandle xMutex;
/* Variables used to detect and latch errors. */
static volatile portBASE_TYPE xErrorOccurred = pdFALSE, xControllingIsSuspended = pdFALSE, xBlockingIsSuspended = pdFALSE;
static volatile unsigned portBASE_TYPE uxControllingCycles = 0, uxBlockingCycles = 0, uxPollingCycles = 0;
/* Handles of the two higher priority tasks, required so they can be resumed
(unsuspended). */
static xTaskHandle xControllingTaskHandle, xBlockingTaskHandle;
/*-----------------------------------------------------------*/
void vStartRecursiveMutexTasks( void )
{
/* Just creates the mutex and the three tasks. */
xMutex = xSemaphoreCreateRecursiveMutex();
/* vQueueAddToRegistry() adds the mutex to the registry, if one is
in use. The registry is provided as a means for kernel aware
debuggers to locate mutex and has no purpose if a kernel aware debugger
is not being used. The call to vQueueAddToRegistry() will be removed
by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is
defined to be less than 1. */
vQueueAddToRegistry( ( xQueueHandle ) xMutex, ( signed portCHAR * ) "Recursive_Mutex" );
if( xMutex != NULL )
{
xTaskCreate( prvRecursiveMutexControllingTask, ( signed portCHAR * ) "Rec1Ctrl", configMINIMAL_STACK_SIZE, NULL, recmuCONTROLLING_TASK_PRIORITY, &xControllingTaskHandle );
xTaskCreate( prvRecursiveMutexBlockingTask, ( signed portCHAR * ) "Rec2Blck", configMINIMAL_STACK_SIZE, NULL, recmuBLOCKING_TASK_PRIORITY, &xBlockingTaskHandle );
xTaskCreate( prvRecursiveMutexPollingTask, ( signed portCHAR * ) "Rec3Poll", configMINIMAL_STACK_SIZE, NULL, recmuPOLLING_TASK_PRIORITY, NULL );
}
}
/*-----------------------------------------------------------*/
static void prvRecursiveMutexControllingTask( void *pvParameters )
{
unsigned portBASE_TYPE ux;
/* Just to remove compiler warning. */
( void ) pvParameters;
for( ;; )
{
/* Should not be able to 'give' the mutex, as we have not yet 'taken'
it. The first time through, the mutex will not have been used yet,
subsequent times through, at this point the mutex will be held by the
polling task. */
if( xSemaphoreGiveRecursive( xMutex ) == pdPASS )
{
xErrorOccurred = pdTRUE;
}
for( ux = 0; ux < recmuMAX_COUNT; ux++ )
{
/* We should now be able to take the mutex as many times as
we like.
The first time through the mutex will be immediately available, on
subsequent times through the mutex will be held by the polling task
at this point and this Take will cause the polling task to inherit
the priority of this task. In this case the block time must be
long enough to ensure the polling task will execute again before the
block time expires. If the block time does expire then the error
flag will be set here. */
if( xSemaphoreTakeRecursive( xMutex, recmuFIVE_TICK_DELAY ) != pdPASS )
{
xErrorOccurred = pdTRUE;
}
/* Ensure the other task attempting to access the mutex (and the
other demo tasks) are able to execute to ensure they either block
(where a block time is specified) or return an error (where no
block time is specified) as the mutex is held by this task. */
vTaskDelay( recmuSHORT_DELAY );
}
/* For each time we took the mutex, give it back. */
for( ux = 0; ux < recmuMAX_COUNT; ux++ )
{
/* Ensure the other task attempting to access the mutex (and the
other demo tasks) are able to execute. */
vTaskDelay( recmuSHORT_DELAY );
/* We should now be able to give the mutex as many times as we
took it. When the mutex is available again the Blocking task
should be unblocked but not run because it has a lower priority
than this task. The polling task should also not run at this point
as it too has a lower priority than this task. */
if( xSemaphoreGiveRecursive( xMutex ) != pdPASS )
{
xErrorOccurred = pdTRUE;
}
}
/* Having given it back the same number of times as it was taken, we
should no longer be the mutex owner, so the next give should fail. */
if( xSemaphoreGiveRecursive( xMutex ) == pdPASS )
{
xErrorOccurred = pdTRUE;
}
/* Keep count of the number of cycles this task has performed so a
stall can be detected. */
uxControllingCycles++;
/* Suspend ourselves so the blocking task can execute. */
xControllingIsSuspended = pdTRUE;
vTaskSuspend( NULL );
xControllingIsSuspended = pdFALSE;
}
}
/*-----------------------------------------------------------*/
static void prvRecursiveMutexBlockingTask( void *pvParameters )
{
/* Just to remove compiler warning. */
( void ) pvParameters;
for( ;; )
{
/* This task will run while the controlling task is blocked, and the
controlling task will block only once it has the mutex - therefore
this call should block until the controlling task has given up the
mutex, and not actually execute past this call until the controlling
task is suspended. */
if( xSemaphoreTakeRecursive( xMutex, portMAX_DELAY ) == pdPASS )
{
if( xControllingIsSuspended != pdTRUE )
{
/* Did not expect to execute until the controlling task was
suspended. */
xErrorOccurred = pdTRUE;
}
else
{
/* Give the mutex back before suspending ourselves to allow
the polling task to obtain the mutex. */
if( xSemaphoreGiveRecursive( xMutex ) != pdPASS )
{
xErrorOccurred = pdTRUE;
}
xBlockingIsSuspended = pdTRUE;
vTaskSuspend( NULL );
xBlockingIsSuspended = pdFALSE;
}
}
else
{
/* We should not leave the xSemaphoreTakeRecursive() function
until the mutex was obtained. */
xErrorOccurred = pdTRUE;
}
/* The controlling and blocking tasks should be in lock step. */
if( uxControllingCycles != ( uxBlockingCycles + 1 ) )
{
xErrorOccurred = pdTRUE;
}
/* Keep count of the number of cycles this task has performed so a
stall can be detected. */
uxBlockingCycles++;
}
}
/*-----------------------------------------------------------*/
static void prvRecursiveMutexPollingTask( void *pvParameters )
{
/* Just to remove compiler warning. */
( void ) pvParameters;
for( ;; )
{
/* Keep attempting to obtain the mutex. We should only obtain it when
the blocking task has suspended itself, which in turn should only
happen when the controlling task is also suspended. */
if( xSemaphoreTakeRecursive( xMutex, recmuNO_DELAY ) == pdPASS )
{
/* Is the blocking task suspended? */
if( ( xBlockingIsSuspended != pdTRUE ) || ( xControllingIsSuspended != pdTRUE ) )
{
xErrorOccurred = pdTRUE;
}
else
{
/* Keep count of the number of cycles this task has performed
so a stall can be detected. */
uxPollingCycles++;
/* We can resume the other tasks here even though they have a
higher priority than the polling task. When they execute they
will attempt to obtain the mutex but fail because the polling
task is still the mutex holder. The polling task (this task)
will then inherit the higher priority. The Blocking task will
block indefinitely when it attempts to obtain the mutex, the
Controlling task will only block for a fixed period and an
error will be latched if the polling task has not returned the
mutex by the time this fixed period has expired. */
vTaskResume( xBlockingTaskHandle );
vTaskResume( xControllingTaskHandle );
/* The other two tasks should now have executed and no longer
be suspended. */
if( ( xBlockingIsSuspended == pdTRUE ) || ( xControllingIsSuspended == pdTRUE ) )
{
xErrorOccurred = pdTRUE;
}
/* Release the mutex, disinheriting the higher priority again. */
if( xSemaphoreGiveRecursive( xMutex ) != pdPASS )
{
xErrorOccurred = pdTRUE;
}
}
}
#if configUSE_PREEMPTION == 0
{
taskYIELD();
}
#endif
}
}
/*-----------------------------------------------------------*/
/* This is called to check that all the created tasks are still running. */
portBASE_TYPE xAreRecursiveMutexTasksStillRunning( void )
{
portBASE_TYPE xReturn;
static unsigned portBASE_TYPE uxLastControllingCycles = 0, uxLastBlockingCycles = 0, uxLastPollingCycles = 0;
/* Is the controlling task still cycling? */
if( uxLastControllingCycles == uxControllingCycles )
{
xErrorOccurred = pdTRUE;
}
else
{
uxLastControllingCycles = uxControllingCycles;
}
/* Is the blocking task still cycling? */
if( uxLastBlockingCycles == uxBlockingCycles )
{
xErrorOccurred = pdTRUE;
}
else
{
uxLastBlockingCycles = uxBlockingCycles;
}
/* Is the polling task still cycling? */
if( uxLastPollingCycles == uxPollingCycles )
{
xErrorOccurred = pdTRUE;
}
else
{
uxLastPollingCycles = uxPollingCycles;
}
if( xErrorOccurred == pdTRUE )
{
xReturn = pdFAIL;
}
else
{
xReturn = pdTRUE;
}
return xReturn;
}

@ -64,10 +64,11 @@
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configTICK_RATE_HZ ( ( portTickType ) 50 )
#define configTICK_RATE_HZ ( 50 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) /* This parameter has no effect when heap_3.c is included in the project. */
#define configMAX_TASK_NAME_LEN ( 12 )
@ -105,4 +106,47 @@ to exclude the API function. */
#define INCLUDE_xTaskGetSchedulerState 1
/* When switching threads, Windows does not always seem to run the selected
thread immediately. This function can be called to check if the thread
that is currently running is the thread that is responsible for executing
the task selected by the real time scheduler. If not then a yield is performed
which will try and force the running thread to block on a semaphore, and hence
allow the thread that should be running to take over. The trace macros are a
convenient way of lacing the code with these checking calls. */
void vPortCheckCorrectThreadIsRunning( void );
#define traceBLOCKING_ON_QUEUE_RECEIVE(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceBLOCKING_ON_QUEUE_SEND(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceGIVE_MUTEX_RECURSIVE(pxMutex) vPortCheckCorrectThreadIsRunning();(void)pxMutex
#define traceQUEUE_CREATE(pxNewQueue) vPortCheckCorrectThreadIsRunning();(void)pxNewQueue
#define traceQUEUE_CREATE_FAILED() vPortCheckCorrectThreadIsRunning()
#define traceCREATE_MUTEX(pxNewMutex) vPortCheckCorrectThreadIsRunning();(void)pxNewMutex
#define traceCREATE_MUTEX_FAILED() vPortCheckCorrectThreadIsRunning()
#define traceGIVE_MUTEX_RECURSIVE(pxMutex) vPortCheckCorrectThreadIsRunning();(void)pxMutex
#define traceGIVE_MUTEX_RECURSIVE_FAILED(pxMutex) vPortCheckCorrectThreadIsRunning();(void)pxMutex
#define traceTAKE_MUTEX_RECURSIVE(pxMutex) vPortCheckCorrectThreadIsRunning();(void)pxMutex
#define traceTAKE_MUTEX_RECURSIVE_FAILED(pxMutex) vPortCheckCorrectThreadIsRunning();(void)pxMutex
#define traceCREATE_COUNTING_SEMAPHORE() vPortCheckCorrectThreadIsRunning()
#define traceCREATE_COUNTING_SEMAPHORE_FAILED() vPortCheckCorrectThreadIsRunning()
#define traceQUEUE_SEND(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_SEND_FAILED(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_RECEIVE(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_RECEIVE_FAILED(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_PEEK(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_SEND_FROM_ISR(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_SEND_FROM_ISR_FAILED(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_RECEIVE_FROM_ISR(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_RECEIVE_FROM_ISR_FAILED(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceQUEUE_DELETE(pxQueue) vPortCheckCorrectThreadIsRunning();(void)pxQueue
#define traceTASK_CREATE(pxTask) vPortCheckCorrectThreadIsRunning();(void)pxTask
#define traceTASK_CREATE_FAILED(pxNewTCB) vPortCheckCorrectThreadIsRunning();(void)pxNewTCB
#define traceTASK_DELETE(pxTask) vPortCheckCorrectThreadIsRunning();(void)pxTask
#define traceTASK_DELAY_UNTIL() vPortCheckCorrectThreadIsRunning()
#define traceTASK_DELAY() vPortCheckCorrectThreadIsRunning()
#define traceTASK_PRIORITY_SET(pxTask,uxNewPriority) vPortCheckCorrectThreadIsRunning();(void)pxTask;(void)uxNewPriority
#define traceTASK_SUSPEND(pxTask) vPortCheckCorrectThreadIsRunning();(void)pxTask
#define traceTASK_RESUME(pxTask) vPortCheckCorrectThreadIsRunning();(void)pxTask
#define traceTASK_RESUME_FROM_ISR(pxTask) vPortCheckCorrectThreadIsRunning();(void)pxTask
#endif /* FREERTOS_CONFIG_H */

Binary file not shown.

@ -95,7 +95,7 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -105,13 +105,14 @@
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalIncludeDirectories>..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0c09</Culture>
</ResourceCompile>
<Link>
<OutputFile>.\Release/WIN32.exe</OutputFile>
<OutputFile>.\Release/RTOSDemo.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<ProgramDatabaseFile>.\Release/WIN32.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
@ -131,8 +132,8 @@
<ClCompile Include="..\Common\Minimal\integer.c" />
<ClCompile Include="..\Common\Minimal\PollQ.c" />
<ClCompile Include="..\Common\Minimal\QPeek.c" />
<ClCompile Include="..\Common\Minimal\recmutex.c" />
<ClCompile Include="..\Common\Minimal\semtest.c" />
<ClCompile Include="DemosModifiedForLowTickRate\recmutex.c" />
<ClCompile Include="main.c">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>

@ -29,6 +29,9 @@
<Filter Include="FreeRTOS Source\Source\Portable">
<UniqueIdentifier>{88f409e6-d396-4ac5-94bd-7a99c914be46}</UniqueIdentifier>
</Filter>
<Filter Include="Demo App Source\Common Demo Tasks\ModifiedForLowTickRate">
<UniqueIdentifier>{143cf5a3-f134-4439-9f71-a201ae23b44b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c">
@ -64,9 +67,6 @@
<ClCompile Include="..\Common\Minimal\QPeek.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\recmutex.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\semtest.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
@ -76,6 +76,9 @@
<ClCompile Include="..\Common\Minimal\blocktim.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="DemosModifiedForLowTickRate\recmutex.c">
<Filter>Demo App Source\Common Demo Tasks\ModifiedForLowTickRate</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Board.h">

@ -51,6 +51,39 @@
licensing and training services.
*/
/*
*******************************************************************************
* -NOTE- The Win32 port is a simulation (or is that emulation?) only! Do not
* expect to get real time behaviour from the Win32 port or this demo
* application. It is provided as a convenient development and demonstration
* test bed only. Also, at the time of writing, a method of deleting theads
* has not been implemented, although doing so would be trivial so this
* functionality might be added in at a later date. At present, calling
* vTaskDelete() will delete the real time task from FreeRTOS but not the Win32
* thread in which the task was executing. DO NOT CALL vTaskDelete() when using
* the Win32 port! This was tested using Windows XP on a dual core laptop.
*
* - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
*******************************************************************************
*
* main() creates all the demo application tasks, then starts the scheduler.
* The web documentation provides more details of the standard demo application
* tasks, which provide no particular functionality but do provide a good
* example of how to use the FreeRTOS API.
*
* In addition to the standard demo tasks, the following tasks and tests are
* defined and/or created within this file:
*
* "Check" task - This only executes every five seconds but has a high priority
* 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 "OK" and the current simulated tick
* time. If an error is discovered in the execution of a task then the check
* task will print out an appropriate error message.
*
*/
/* Standard includes. */
#include <stdio.h>
@ -64,7 +97,6 @@
#include "BlockQ.h"
#include "death.h"
#include "integer.h"
//#include "blocktim.h"
#include "semtest.h"
#include "PollQ.h"
#include "GenQTest.h"
@ -94,14 +126,6 @@ static xQueueHandle xStdoutQueue = NULL;
/* Task function prototypes. */
static void prvCheckTask( void *pvParameters );
/* Create a queue on which console output strings can be posted, then start the
task that processes the queue - printf()'ing each string that is received. */
static void prvStartStdoutTask( void );
/* Post a message for output by the stdout task. Basically queues the message
pointed to by pcTextToPrint for output to stdout in a thread safe manner. */
void vMainConsolePrint( const char *pcTextToPrint, portTickType xTicksToWait );
/*-----------------------------------------------------------*/
int main( void )
@ -111,14 +135,13 @@ int main( void )
/* Create the standard demo tasks. */
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
// vCreateBlockTimeTasks();
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
vStartQueuePeekTasks();
vStartRecursiveMutexTasks();
vStartMathTasks( mainFLOP_TASK_PRIORITY );
vStartRecursiveMutexTasks();
/* Start the scheduler itself. */
vTaskStartScheduler();
@ -134,7 +157,6 @@ static void prvCheckTask( void *pvParameters )
portTickType xNextWakeTime;
const portTickType xCycleFrequency = 5000 / portTICK_RATE_MS;
char *pcStatusMessage = "OK";
long lCycleCount = 0;
/* Just to remove compiler warning. */
( void ) pvParameters;
@ -164,10 +186,6 @@ long lCycleCount = 0;
{
pcStatusMessage = "Error: BlockQueue";
}
// else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
// {
// pcStatusMessage = "Error: BlockTime";
// }
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: SemTest";
@ -175,15 +193,15 @@ long lCycleCount = 0;
else if( xArePollingQueuesStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: PollQueue";
}
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: RecMutex";
}
else if( xAreMathsTaskStillRunning() != pdPASS )
{
pcStatusMessage = "Error: Flop";
}
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: RecMutex";
}
/* This is the only task that uses stdout so its ok to call printf()
directly. */

Loading…
Cancel
Save