How to switch thread stack between threads?

Alexander Tormasov a.tormasov at innopolis.ru
Wed Jul 14 02:12:07 CEST 2021


Hello,
I see that it is possible to have 1 thread with multiple stacks, using alloc_secondary_stack() call.
But if I want to switch stack
From one OS thread to another one for setcontext()?

Stack do contain hidden data related to Stack structure and to the native UCB (completely opaque). If I try to use it, it try to find stored structure which contains thread reference, which point to old thread. I need to point it to the new thread 

In particular , it interfere with thread local storage TLS data, it use wrong content from old thread because it use stack content for thread identification , and fail…

How to do this, any ideas?
I can’t re-create it - it contains state of the thread , not the best idea to copy content of stack during every context switch …


Alexander

Отправлено с iPhone


More information about the users mailing list