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] [January 2006 Threads] CRITICAL and returnPosted by Nobody/Anonymous on January 17, 2006 Sorry - this maybe a repost - I'm not sure my first atempt made it through my ADSL which is playing up this morning...
The question is, is it okay to return a global variable inside a critical section :-
inline unsigned short MessagesToSend( void ) { taskENTER_CRITICAL(); return m_MessagesToSend; taskEXIT_CRITICAL(); }
rather than the more secure, but slower :-
inline unsigned short MessagesToSend( void ) { unsigned short Val; taskENTER_CRITICAL(); Val = m_MessagesToSend; taskEXIT_CRITICAL(); return Val; }
TIA
Tim (@vaquita.co.uk)
RE: CRITICAL and returnPosted by Nobody/Anonymous on January 17, 2006 Unfortunately not. This could/would (depending on the port) exit the function with interrupts disabled, leave the stack incorrect and thus not return correctly.
RE: CRITICAL and returnPosted by Nobody/Anonymous on January 17, 2006 Also note the inline request. I assume that if the compiler does inline it, it will be fine. Maybe not though. I'm just not convinced what will happen if it doesn't.
Basically, will the EXIT_CRITICAL bit get called, or will the compiler do what I'm telling it to, and just skip to the end of the routine ?
: :
Okay, I think I've answered my question. If the compiler is more clever than I think, and fix my dumb errors, then let me know...
Tim
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|