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


using setjmp and longjmp

Posted by joe_her on October 16, 2016

Is it OK to use longjmp inside a task? What if I have an error detected deeply nested, and I want to jump to a "clean" location in the task ( for example some error in communication hardware, needs to restart it, etc.) Thanks

using setjmp and longjmp

Posted by rtel on October 16, 2016

I have to be honest and say I have no idea, although I would suspect not unless you can find some way of making it thread aware. I have used these functions to jump from a running FreeRTOS application back to a host environment, but not within a task.

using setjmp and longjmp

Posted by richard_damon on October 16, 2016

My guess is that a setjmp/longjmp within a single task will likely work (and between tasks will cause all sorts of problems). setjmp/longjmp shouldn't have thread issue themselves, as all the information should be in the jmpbuf, but they would have no knowledge of how to change threads.

using setjmp and longjmp

Posted by happygimp0 on February 17, 2017

Possible Problem with Microcontrollers which need more then a single instruction to manipulate the stack pointer: In longjmp() you change the stack pointer, while you change it, a scheduler interrupt can happen, scheduler want to store the current registers on stack, the stack pointer points on a more or less random location and the push commands rewrite some random locations. Such a bug will be very hard to find, it is very unlikely that the timer interrupt is exactly at this moment and it is possible that you overwrite always other places.

[ 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