Ejemplo n.º 1
0
static void prvQueueSetSendingTask( void *pvParameters )
{
unsigned long ulTaskTxValue = 0, ulQueueToWriteTo;
xQueueHandle xQueueInUse;

	/* Remove compiler warning about the unused parameter. */
	( void ) pvParameters;

	/* Seed mini pseudo random number generator. */
	prvSRand( ( unsigned long ) &ulTaskTxValue );

	for( ;; )
	{
		/* Generate the index for the queue to which a value is to be sent. */
		ulQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
		xQueueInUse = xQueues[ ulQueueToWriteTo ];

		/* Note which index is being written to to ensure all the queues are
		used. */
		( ulQueueUsedCounter[ ulQueueToWriteTo ] )++;

		/* Send to the queue to unblock the task that is waiting for data to
		arrive on a queue within the queue set to which this queue belongs. */
		if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
		{
			/* The send should always pass as an infinite block time was
			used. */
			xQueueSetTasksStatus = pdFAIL;
		}

		#if( configUSE_PREEMPTION == 0 )
			taskYIELD();
		#endif

		ulTaskTxValue++;

		/* If the Tx value has reached the range used by the ISR then set it
		back to 0. */
		if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
		{
			ulTaskTxValue = 0;
		}

		/* Increase test coverage by occasionally change the priorities of the
		two tasks relative to each other. */
		prvChangeRelativePriorities();
	}
}
Ejemplo n.º 2
0
static TickType_t prvGetNextDelayTime( void )
{
TickType_t xNextDelay;
const TickType_t xMaxDelay = pdMS_TO_TICKS( ( TickType_t ) 150 );
const TickType_t xMinDelay = pdMS_TO_TICKS( ( TickType_t ) 75 );
const TickType_t xTinyDelay = pdMS_TO_TICKS( ( TickType_t ) 2 );

	/* Generate the next delay time.  This is kept within a narrow band so as
	not to disturb the timing of other tests - but does add in some pseudo
	randomisation into the tests. */
	do
	{
		xNextDelay = prvRand() % xMaxDelay;

		/* Just in case this loop is executed lots of times. */
		vTaskDelay( xTinyDelay );

	} while ( xNextDelay < xMinDelay );

	return xNextDelay;
}
Ejemplo n.º 3
0
static void prvNotifiedTask( void *pvParameters )
{
const TickType_t xMaxPeriod = pdMS_TO_TICKS( 90 ), xMinPeriod = pdMS_TO_TICKS( 10 ), xDontBlock = 0;
TickType_t xPeriod;

	/* Remove compiler warnings about unused parameters. */
	( void ) pvParameters;

	/* Run a few tests that can be done from a single task before entering the
	main loop. */
	prvSingleTaskTests();

	/* Create the software timer that is used to send notifications to this
	task.  Notifications are also received from an interrupt. */
	xTimer = xTimerCreate( "Notifier", xMaxPeriod, pdFALSE, NULL, prvNotifyingTimer );

	for( ;; )
	{
		/* Start the timer again with a different period.  Sometimes the period
		will be higher than the tasks block time, sometimes it will be lower
		than the tasks block time. */
		xPeriod = prvRand() % xMaxPeriod;
		if( xPeriod < xMinPeriod )
		{
			xPeriod = xMinPeriod;
		}

		/* Change the timer period and start the timer. */
		xTimerChangePeriod( xTimer, xPeriod, portMAX_DELAY );

		/* Block waiting for the notification again with a different period.
		Sometimes the period will be higher than the tasks block time, sometimes
		it will be lower than the tasks block time. */
		xPeriod = prvRand() % xMaxPeriod;
		if( xPeriod < xMinPeriod )
		{
			xPeriod = xMinPeriod;
		}

		/* Block to wait for a notification but without clearing the
		notification count, so only add one to the count of received
		notifications as any other notifications will remain pending. */
		if( ulTaskNotifyTake( pdFALSE, xPeriod ) != 0 )
		{
			ulTimerNotificationsReceived++;
		}


		/* Take a notification without clearing again, but this time without a
		block time specified. */
		if( ulTaskNotifyTake( pdFALSE, xDontBlock ) != 0 )
		{
			ulTimerNotificationsReceived++;
		}

		/* Wait for the next notification from the timer, clearing all
		notifications if one is received, so this time adding the total number
		of notifications that were pending as none will be left pending after
		the function call. */
		ulTimerNotificationsReceived += ulTaskNotifyTake( pdTRUE, xPeriod );

		/* Wait for the next notification again, clearing all notifications if
		one is received, but this time blocking indefinitely. */
		ulTimerNotificationsReceived += ulTaskNotifyTake( pdTRUE, portMAX_DELAY );

		/* Incremented to show the task is still running. */
		ulNotifyCycleCount++;
	}
}