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


Behavior of critical section inside a task

Posted by aamir mahmood on June 12, 2009


I have a question on the behavior of critical section procession (portENTER_CRITICAL( ) and portEXIT_CRITICAL( )). As I understood all the interrupts other that SWI are disabled as the code execution enters into the critical section.

Assuming a taskA with priority 1 is allocated with its time slice by the scheduler and taskA have just entered into the critical section of the code. While the code inside the critical section is executing, the taskA time slice expires and another taskB with higher priority 2 goes into the ready state. The question is, will critical section be able protect the taskA from being preempted by taskB? If not what could be done to prevent a higher priority task from preempting a lower priority task which is doing something critical.

Best regards,

RE: Behavior of critical section inside a task

Posted by Richard Damon on June 12, 2009
When you enter the critical section, the interrupts (or at least those involved that interact with scheduling) are disabled. When the time slice ends, the hardware will set the request for the timer interrupt, but the interrupt will not actually occur (since it is disabled) so nothing will cause the task switch. When the critical section ends, the interrupt will occur, and taskB will get switched in, but none of this happens until the critical section is over.

[ 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