Quality RTOS & Embedded Software

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



Posted by chinamay kumar on April 29, 2008
Hi all,,

After a long time I am able to run multiple task at same priority. But not able to do multitasking for different priorities.

So can anybody tell me to do multitaking at different priorities or i have to do some changes in kernal.
here i am mentioning a situation......

Let us assume we have two tasks task1 and task2.Task1 has higher priority than task2.Initially my task1 is running but a delay call come and than i want to execute my task2.

At the same priority i am able to execute task2 but not at different prorities.

Please reply soon.


RE: FreeRTOS_Scheduler

Posted by Neil Bradley on April 29, 2008
You'll need to make sure that Task1 blocks on a kernel object (semaphore, mutex, event flag, queue, etc...) so Task1 will go to sleep, otherwise Task2 will never execute.

RE: FreeRTOS_Scheduler

Posted by incrediball on April 29, 2008
You certainly do not need to change the kernel. Task2 will run when task1 is suspended, e.g. by a delay, when waiting for a semaphore or an item to appear in a queue, etc. What does not work is if task1 only calls taskYIELD since the yield will only allow a switch to other tasks of equal or higher priority.

RE: FreeRTOS_Scheduler

Posted by chinamay kumar on April 29, 2008
check my application part in which i made two task ....and try to run...

int main( void )
xTaskCreate( MyTask1, ( signed portCHAR * ) "MyTask1",
xTaskCreate( MyTask2, ( signed portCHAR * ) "MyTask2", configMINIMAL_STACK_SIZE, NULL, 1, NULL );

/* Now all the tasks have been started - start the scheduler.
/* Will only get here if there was insufficient memory to create the idle
task. */
return 0;
static void MyTask1( void )
printf("Chinmay Task 1\n\r");
//vTaskDelay( 10 );
printf("Chinmay Task 1 end\n\r");
static void MyTask2( void )
printf("Chinmay Task 2\n\r");
void SleepMs(uint32_t ms)
//Actual clock speed 14.745 MHz
//One sec = 14745,000 Cycles
//One msec = 14745 Cycles

uint32_t i;
ms *= 14745;
for(i=0; i<ms; i++) nop();

Here printf is used through uart0 in polling mode and my tick int occure after every 3 ms.

I want to execute my task 2 when task 1 is in sleep mode.
So sseing above can you suggest me anything.

Many thanks in advance

RE: FreeRTOS_Scheduler

Posted by Richard on April 29, 2008
SleepMs() never blocks, it stays within the function for the requested amount of time, but during this time it uses maximum CPU processing time to execute your null loop. As it does not block it is ready to run, and as the highest priority task it will always be the task that is selected to run. In other words you are seeing the expected behaviour whereby the low priority task is starved of processing time by a higher priority task that never leaves the Ready/Running state.

If the higher priority task blocked then it would not consume CPU time and the lower priority task would execute. This is achieved by replacing the null loop with vTaskDelay() or vTaskDelayUntil().


RE: FreeRTOS_Scheduler

Posted by chinamay kumar on April 29, 2008
I realised that and try vtaskdelay()function as u can see in my code but after using that no prints available.
So please u also check that code with vtaskdelay().

Many thanks in advance.

RE: FreeRTOS_Scheduler

Posted by incrediball on April 29, 2008
If you are using vTaskDelay then task2 will run. However was the delay really only for 10 ticks as shown by the commented out line in your program? Try a longer delay as this might not be enough time for the printf and its rs232 transmission to complete. Another possibility is that your configuration (see your FreeRTOSConfig.h) is not setting up enough heap space for the two tasks (try reversing the creation order of the two tasks and see if it makes any difference) or enough priority levels. Also try selecting pre-emptive multitasking if you haven't done so already.

RE: FreeRTOS_Scheduler

Posted by chinamay kumar on April 30, 2008
when i am not using vtaskdelay() i am able to run both tasks at same priority but when i use vtaskdelay() it m task2 is not executing.I also increase tick and reversing the task creation as u suggest but getting same result as earlier.
If Heap memory is less than last task will not create and i am using premptive scheduling.

I observe that when i call vtaskdelay() it will not go beyond portyield() which is a macro asm("SWI").

RE: FreeRTOS_Scheduler

Posted by chinamay kumar on May 1, 2008
Hi All,

I am trying to execute my low priority task by halting high priority task.
For that i tried vtaskdelay and vtasksuspend functions but after calling them no task is working.

so plz tell me to suspend a task we have to only call vtasksuspend and ou next low priority task starts resume without any modification?

Reply as soon as possible.

RE: FreeRTOS_Scheduler

Posted by chinamay kumar on May 1, 2008
NOw i am able to run low priority task by delaying high priority task using vtaskdelay but my high priority task is not resuming after expire of delay period and after delay period my low priority task also not running.

What can be the problem...

RE: FreeRTOS_Scheduler

Posted by PICmeup on May 1, 2008
sound like your tick interrupt not running. Verify that the tick is working.

RE: FreeRTOS_Scheduler

Posted by chinamay kumar on May 2, 2008
My tick interrupt is working.
Any other suggestion>
Can u tell me after expire of delay time how dealyed task is resume?

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists