EmbeddedRelated.com
Forums

"Boost context" for task switching on embedded Linux on ARM

Started by Unknown August 3, 2018
On 18-08-09 17:55 , George Neuner wrote:
> On Wed, 8 Aug 2018 08:21:08 +0300, Niklas Holsti > <niklas.holsti@tidorum.invalid> wrote: > >> The undefinedness of a cross-thread longjmp can be far more serious >> than, say, shifting or overflowing a signed integer. A longjmp is >> intended to *abandon* the current execution point and return to a point >> *lower* (earlier) in the call stack. Some C or C++ systems might >> implement this by unwinding the stack, frame by frame, until the setjmp >> frame is reached. This will have drastic "undefinedness" if the setjmp >> refers to another stack... > > But none do ... every implementation I have seen leaves the stack data > intact and simply resets the CPU register(s).
Ok, but that is not proof that "none do".
> longjmp is NOT equivalent to throwing an exception, and, in fact, it > is dangerous to use it that way in C++. Using longjmp will NOT cause > destructors to be called for local objects on the "abandoned" stack.
You cannot know if it will, or won't; it's explicitly undefined in the C++ standard.
>> It is not advisable, today, to try to misuse setjmp/longjmp for thread >> switching. > > I already said that I don't advocate doing it, and that I merely was > explaining it to the OP.
We agree.
> Maybe you prefer to conceal information about things you don't like, > but I prefer to educate people and let them make up their own minds.
Becoming irritated, are we? I'll stop here. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .