Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

2 Task by non-preemptive mode

Posted by daruse on 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_PREEMPTION0
#define configUSE_IDLE_HOOK0
#define configUSE_TICK_HOOK0
#define configTICK_RATE_HZ( ( portTickType ) 1000 ) // 1 Millisekunde
#define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 5 )


RE: 2 Task by non-preemptive mode

Posted by daruse on 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++}
}

RE: 2 Task by non-preemptive mode

Posted by Dave on 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();}
}”

RE: 2 Task by non-preemptive mode

Posted by daruse on January 17, 2012
Thanks, now will both tasks executed.

RE: 2 Task by non-preemptive mode

Posted by daruse on 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


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS