aeyes wrote on Monday, October 20, 2008:
Hi I copied the preemptive multitasking program which I copied from the Coldfire RTOS port from the website ,
I am constantly getting the following output
Task 0 running.
Task 0 running.
Task 0 running.
Task 0 running.
.
.
.
and so on
Here is the code I have copied , what could be the problem ?
I feel that the task id is not getting passed properly
Please help .
Pasting the code section below . Thank you.
static void vTestTask( void *pvParameters );
static int task1id = 1;
static int task2id = 2;
static int task3id = 3;
static int task4id = 4;
xSemaphoreHandle xSemaphore = NULL;
portSHORT main( void )
{
xTaskCreate( vTestTask, "Task 1", 1000,(void *)&task1id, tskIDLE_PRIORITY + 2, NULL );
xTaskCreate( vTestTask, "Task 2", 1000,(void *)&task2id, tskIDLE_PRIORITY + 2, NULL );
xTaskCreate( vTestTask, "Task 3", 1000,(void *)&task3id, tskIDLE_PRIORITY + 2, NULL );
xTaskCreate( vTestTask, "Task 4", 1000,(void *)&task4id, tskIDLE_PRIORITY + 2, NULL );
my_printf("starting scheduler…\n");
vSemaphoreCreateBinary( xSemaphore );
vTaskStartScheduler();
return 0;
}
/*-----------------------------------------*/
static void vTestTask( void *pvParameters )
{
int taskId = *((int *)pvParameters);
for(;
{
if ( xSemaphoreTake( xSemaphore, 0 ) )
{
my_printf("Task %d running.\n", taskId);
xSemaphoreGive( xSemaphore );
}
}
}