FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2011 Threads] 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!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|