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

Definition of Context Switch in RTOS?

Posted by Ivan on March 22, 2011
Hi there,

I am new to FreeRTOS and the concepts of RTOS in general. I was wondering, in this situation:

When a RTOS is running and an interrupt arrives, which subsequently invokes a yeidlFromISR() function, does that constitute a "context switch" as per in the normal Time sharing desktop systems ?

I have been looking around for awhile but have yet to find the definitive answer on this. To me, as long as an execution context is preempted and can be restored for execution subsequently is considered a context switch. Am I mistaken in my understanding?

Thanks alot in advance, any help in understanding is appreciated :)

Cheers!

RE: Definition of Context Switch in RTOS?

Posted by MEdwards on March 22, 2011
“When a RTOS is running and an interrupt arrives, which subsequently invokes a yeidlFromISR() function, does that constitute a "context switch" as per in the normal Time sharing desktop systems ?”


Calling portYIELD_FROM_ISR() from an interrupt context switches the context of the task that was interrupted, to the task that should run when the interrupt completes. That means, the interrupt interrupts one task, but potentially returns to another. The task that was interrupted will run again, but only when it is the highest priority ready state task. So yes, that is a context switch, but the context switch does not switch the interrupt context but the task context. I don't know how that relates to your question about time sharing desktop systems though.

Does that answer your question?

RE: Definition of Context Switch in RTOS?

Posted by Ivan on March 22, 2011
Oh yes! That was a great answer. Yes, I see what you mean now and that makes so much more sense!

Thanks alot! Cheers :)

RE: Definition of Context Switch in RTOS?

Posted by Ivan on March 23, 2011
Hi,

I didn't want to start a new thread and flood the forum so I decided to continue off from here.

I am new to FreeRTOS and the concepts of RTOS in general. I am wondering, if this is what happens during the execution of the Kernel on a Renesas RSK RX62N or any other MCUs in general:

1) Kernel is running and sets the Interrupt Priority Level(IPL) to configKERNEL_INTERRUPT_PRIORITY. (Other than the times where the Kernel is accessing Kernel data and needs to disable all interrupts by setting the IPL to configMAX_SYSCALL_INTERRUPT_PRIORITY)

2) When an interrupt arrives, the MCU will check against the current IPL levels to check if the interrupt is allowed to be accepted.

3) If interrupt is accepted: Kernel is preempted and the MCU will switch to the Interrupt Stack Pointer. When the interrupt handler completes, the PC and the Processor Status Word (PSW) is popped off the interrupt stack and finally, Kernel continues executing from where it left of.

Is my understanding correct?

Thanks loads guys :) Cheers!


[ 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