Quality RTOS & Embedded Software

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


Why FreeRTOS is not masking interrupts while doing a context switch in SWI_Handler?

Posted by kbshibukumar on February 28, 2014

In the file FreeRTOS_Demo/Source/FreeRTOS-Source/Portable/RVDS/ARM-CA9/portmacro.h, we have the following definition.

#define portYIELD() __asm( "SWI 0" );

Now, the corresponding SWI handler in portASM.s is

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SVC handler is used to start the scheduler and yield a task. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FreeRTOSSWIHandler ; Check whether an iterrupt can occur at this point. PRESERVE8

; Save the context of the current task and select a new task to run.
LDR R0, =vTaskSwitchContext

vPortRestoreTaskContext portRESTORE_CONTEXT

However, nowhere in the above code, interrupts are disabled. Doesn't it cause any problem if any other interrupt comes and moves a task into the ready queue or schedules a new task in the mean time?

Why FreeRTOS is not masking interrupts while doing a context switch in SWI_Handler?

Posted by davedoors on March 1, 2014

All IRQs are disabled by the hardware, which is why you can't find software doing it. The IRQ handler reenables interrupts so interrupts can nest but the SVC handler doesn't.

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

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

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

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

Xilinx Microblaze and Zynq partner