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




Loading

Help Need with FreeRTOS, Cortex port newbie

Posted by Zhibin Zhang on July 17, 2008
I am a newbie fan of FreeRTOS. It is a great source. I am now looking at FreeRTOS and Cortex-M3 port. Can someone answer my questions?

•To may understanding, at each Systick, the handler sent out a PendSV request and forced a context switch. Is this argument correct? Isn’t this going to waste the processor time? For example, if Fsystick=1kHz, is the processor going to check for and force for context switch for 1000 times in a second? Is there a way for it not switch if it does not need to?

•What is the “CriticalNextingCount” do?


•If there is an interrupt during a task, does the interrupt’s processing time being counted as part of the task? Does Systick still increase during the interrupt handler?

•What is the “SVC 0” mean when start the first task?

Anyway, is there a book by Richard on FreeRTOS? I appreciate any inputs.

RE: Help Need with FreeRTOS, Cortex port newbie

Posted by Richard on July 17, 2008
> I am a newbie fan of FreeRTOS. It is a great source. I am now
> looking at FreeRTOS and Cortex-M3 port. Can someone answer my
> questions?
>
> To may understanding, at each Systick, the handler sent
> out a PendSV request and forced a context switch. Is this
> argument correct?

Yes - the PendSV holds pending until there are not higher priority interrupts running, then runs to select the next task.


> Isnt this going to waste the processor
> time? For example, if Fsystick=1kHz, is the processor going
> to check for and force for context switch for 1000 times in a
> second? Is there a way for it not switch if it does not need to?

You can of course set the tick speed down. 1KHz is used by the demos primarily for test purposes. It is much faster than nearly all applications require.

You could add code to set a flag when there is a context switch required.


>
> What is the CriticalNextingCount do?
>


Critical sections can nest, the critical section nesting count keeps track of the nesting depth and ensures that interrupts are only re-enabled when the nesting count unwinds back to zero. In other words, if two calls to portENTER_CRITICAL() follow each other, then interrupts should not be re-enabled fully until two calls to portEXIT_CRITICAL() have also been made.


>
> If there is an interrupt during a task, does the
> interrupts processing time being counted as part of the task?
> Does Systick still increase during the interrupt handler?
>

The system timer itself increments all the time as it is driven directly from the clock. It is free running no matter what the software is doing.

> What is the SVC 0 mean when start the first task?
>

This is a software interrupt, it puts the processor into the correct state for the first task to be started. You can look up the SVC instruction in the Cortex manual.



> Anyway, is there a book by Richard on FreeRTOS?

Not yet.....

RE: Help Need with FreeRTOS, Cortex port newbie

Posted by Zhibin Zhang on July 17, 2008
Hi Barry,

Thank you very much for your inputs and it helps a lot for me, a newbie. I still have some questions as below,

> To may understanding, at each Systick, the handler sent
> out a PendSV request and forced a context switch. Is this
> argument correct?

Yes - the PendSV holds pending until there are not higher priority interrupts running, then runs to select the next task.


So in the simple case (for example, no other interrupts), no matter what, the PendSV forced a context switch at every tick?

In some case, if there is an interrupt handler lasts more than a tick period. What will be the PendSV and SysTick? Is SysTick still updating? PendSV still initiates? Can they be nested?

Another situation is, if there is a running task and an interrupt is happened; and during the interrupt handler, some higher priority task is ready. What will the system do?
1)intermediately switch to higher priority task during the interrupt handler?
2)Continue to finish interrupt handler first and then return to old task. Then switch to high priority task?


> Isnt this going to waste the processor
> time? For example, if Fsystick=1kHz, is the processor going
> to check for and force for context switch for 1000 times in a
> second? Is there a way for it not switch if it does not need to?

You can of course set the tick speed down. 1KHz is used by the demos primarily for test purposes. It is much faster than nearly all applications require.

You could add code to set a flag when there is a context switch required.


>
> What is the CriticalNextingCount do?
>


Critical sections can nest, the critical section nesting count keeps track of the nesting depth and ensures that interrupts are only re-enabled when the nesting count unwinds back to zero. In other words, if two calls to portENTER_CRITICAL() follow each other, then interrupts should not be re-enabled fully until two calls to portEXIT_CRITICAL() have also been made.

So this is only for critical section? How critical section is related with a task? And I notice it is included in the TCB definition. Is there a purpose for that? Any example.

By the way, do we nest the interrupt in the FreeRTOS?Is there any programming model on this topic?

>
> If there is an interrupt during a task, does the
> interrupts processing time being counted as part of the task?
> Does Systick still increase during the interrupt handler?
>

The system timer itself increments all the time as it is driven directly from the clock. It is free running no matter what the software is doing.

What about the systick interrupt? Is it the lowest priority? Can the other interrupt pre-empt it? What it will do in that case, a higher priority interrupt handler keeps a long time greater than the tick period?


> What is the SVC 0 mean when start the first task?
>

This is a software interrupt, it puts the processor into the correct state for the first task to be started. You can look up the SVC instruction in the Cortex manual.


Can you give me a general idea of the SVC in Cortex port? What is the general function in that SVChandler?


> Anyway, is there a book by Richard on FreeRTOS?

Not yet.....

Any Other tutorial to give a good start on the fundamentals? Can I get a systematic idea of the whole thing.


[ 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