Ejemplo n.º 1
0
void ABlockQ::StartBlockingQueueTasks(CCheckTask *pCheckTask, UBaseType_t nPriority) {
	const UBaseType_t uxQueueSize1 = 1, uxQueueSize5 = 5;
	const TickType_t xBlockTime = ( TickType_t ) 1000 / portTICK_PERIOD_MS;
	const TickType_t xDontBlock = ( TickType_t ) 0;

	// Create the first two tasks as described at the top of the file.

	// Create the queue used by the first two tasks to pass the incrementing number.
	static CQueue queue1;
	queue1.Create(uxQueueSize1, (UBaseType_t) sizeof(unsigned short));
	static CBlockQConsumer consumer1Task(pCheckTask, &queue1, &s_sBlockingConsumerCount[0], xBlockTime);
	static CBlockQProducer producer1Task(pCheckTask, &queue1, &s_sBlockingProducerCount[0], xDontBlock);

	//Note the producer has a lower priority than the consumer when the tasks are spawned.
	consumer1Task.Create("QConsB1", blckqSTACK_SIZE, nPriority);
	producer1Task.Create("QProdB2", blckqSTACK_SIZE, tskIDLE_PRIORITY);

	// Create the second two tasks as described at the top of the file. This uses
	// the same mechanism but reverses the task priorities.
	static CQueue queue2;
	queue2.Create(uxQueueSize1, (UBaseType_t) sizeof(unsigned short));
	static CBlockQConsumer consumer2Task(pCheckTask, &queue2, &s_sBlockingConsumerCount[1], xDontBlock);
	static CBlockQProducer producer2Task(pCheckTask, &queue2, &s_sBlockingProducerCount[1], xBlockTime);
	consumer2Task.Create("QProdB3", blckqSTACK_SIZE, tskIDLE_PRIORITY);
	producer2Task.Create("QConsB4", blckqSTACK_SIZE, nPriority);

	// Create the last two tasks as described above.  The mechanism is again just
	// the same.  This time both parameter structures are given a block time.
	static CQueue queue3;
	queue3.Create(uxQueueSize5, (UBaseType_t) sizeof(unsigned short));
	static CBlockQProducer producer3Task(pCheckTask, &queue3, &s_sBlockingProducerCount[2], xBlockTime);
	static CBlockQConsumer consumer3Task(pCheckTask, &queue3, &s_sBlockingConsumerCount[2], xBlockTime);
	producer3Task.Create("QProdB5", blckqSTACK_SIZE, tskIDLE_PRIORITY);
	consumer3Task.Create("QConsB6", blckqSTACK_SIZE, tskIDLE_PRIORITY);
}
Ejemplo n.º 2
0
void APollQ::StartPolledQueueTasks(CCheckTask *pCheckTask, UBaseType_t nPriority ) {
	static CQueue queue;

	/* Create the queue used by the producer and consumer. */
	queue.Create(pollqQUEUE_SIZE, (UBaseType_t) sizeof(unsigned short));

	/* vQueueAddToRegistry() adds the queue to the queue registry, if one is
	in use.  The queue registry is provided as a means for kernel aware
	debuggers to locate queues 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. */
	queue.AddToRegistry("Poll_Test_Queue");

	/* Spawn the producer and consumer. */
	static CPollQConsumer consumer(pCheckTask, &queue);
	consumer.Create("QConsNB", pollqSTACK_SIZE, nPriority);
	static CPollQProducer producer(pCheckTask, &queue);
	producer.Create("QProdNB", pollqSTACK_SIZE, nPriority);
}