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

difference between taskENTER_CRITICAL and tas

Posted by Yuhui Lin on July 21, 2010
I'm a little confused about the different between taskENTER_CRITICAL and taskDISABLE_INTERRUPTS.

I read the user manual, it said "they working by disabling interrupt......Pre-emptive switch can only occur from interrupt, so as long as interrupt remains disabled, the task called the taskENTER_CRITICAL can guaranteed to remain in running state ". From my understanding, both of them can result in disabled interrupt and context switch. Any tips?

RE: difference between taskENTER_CRITICAL and tas

Posted by Dave on July 21, 2010
ENTER_CRITICAL() keeps a count of the call nesting and is the only one you should use really. It normally calls DISABLE_INTERRUPTS internally.

Some but not all ports can still context switch with interrupts disabled, but not from in a preemptive way because with interrupts being disabled they cannot be preempted.

RE: difference between taskENTER_CRITICAL and tas

Posted by Yuhui Lin on July 21, 2010
thanks davedoors for your answer, but I am still not very clear. Is there any 'extra benefit' ENTER_CRITICAL could provides, besides disabled interrupt.

They seem to be the same to me. I can't tell the differences betweens them. Then I start wonder why do I need two different interface, if they share nearly the same features. I guess there should be something unknown to me.

RE: difference between taskENTER_CRITICAL and tas

Posted by Richard Damon on July 21, 2010
The big difference is the ENTER/EXIT Critical takes into account nesting, Enable/Disable interrupt do not. Thus

ENTER
/* Interrupts now disabled */
ENTER
EXIT
/* Interrupts still disabled */
EXIT
/* unwound all the critical sections, so interrupt now enabled */

While with DISABLE you would get

DISABLE
/* Interrupts now disabled */
DISABLE

ENABLE
/* Interrupts now reenabled even though we disabled twice */
ENABLE


RE: difference between taskENTER_CRITICAL and tas

Posted by Yuhui Lin on July 21, 2010
Aha~ thanks~ I got it now. That's the reason I saw push and pop assembly code in one of the porting file for ENTER_CRITICAL and EXIT_CRITICAL

RE: difference between taskENTER_CRITICAL and tas

Posted by Richard Damon on July 21, 2010
Critical sections should not be storing the "stacking" of them on the stack, but tend to use a counter.

Some ports may use push/pop to access a status/control register. One thing to note is that a critical section may not disable ALL interrupts, but may just disable those interrupts at a level which is allowed to interact with the kernel, and this is sometimes done by setting the current interrupt priority level in the hardware.


[ 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