2 Task by non-preemptive mode

daruse wrote on Monday, January 16, 2012:

Hi,
i have 2 tasks and set non-preemptive mode.
No my problem is, the scheduler calls only the second task. the first task is not running/call.
can somebody help me?

this is main:
  prvSetupHardware();

  xTaskCreate( prvCheckTask, “Check”, configMINIMAL_STACK_SIZE, mainCHECK_PARAMETER, mainCHECK_TASK_PRIORITY, NULL );
 
  xTaskCreate( vRegTest1, “Reg1”, configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
  xTaskCreate( vRegTest2, “Reg2”, configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
         
  /* my tasks */
  xTaskCreate(FKT_TASK1, “Task1”, configMINIMAL_STACK_SIZE, NULL, 5, NULL);      
  xTaskCreate(FKT_TASK2, “Task2”, configMINIMAL_STACK_SIZE, NULL, 5, NULL);      
        
  vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
         
  vTaskStartScheduler();

and the config.h
#define configUSE_PREEMPTION 0
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) // 1 Millisekunde
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )

daruse wrote on Monday, January 16, 2012:

the task1 and task2 are outside from main:

void FKT_TASK1 (void *pvParameters)
{
while[(1){
i1++;}
}

void FKT_TASK1 (void *pvParameters)
{
while(1){
i2++}
}

davedoors wrote on Monday, January 16, 2012:

If you have set the code to non-premtive mode then with those task definitions only one task will ever run. You have told the scheduler not to preempt a task, so the task will carry on running until it takes itself out of the Running state, for example by calling vTaskDelay(), or it explicitly yields, for example by calling taskYIELD().

If you want both tasks to run then they must yeild.

void FKT_TASK1 (void *pvParameters)
{
    while[(1){
    i1++;
    taskYIELD();}
}

void FKT_TASK1 (void *pvParameters)
{
    while(1){
    i2++;
    taskYIELD();}
}

daruse wrote on Tuesday, January 17, 2012:

Thanks, now will both tasks executed.

daruse wrote on Tuesday, January 17, 2012:

I have yet a second question.
Do you know the settings, that the task is called 1 ms?

I have used the vTaskDelayUntil (in every task), but then the scheduler jump into the vRegTestFailed function.
Thanks in advance