I am writing a user space thread library. I have a structure that controls each thread. My threads are very simple, they take the ptr function and its arguments and just run that function once.
Each stream has jmp_buf, and I use setjmp and longjmp to switch between streams. One thing I cannot understand is to find out when this function is completed.
For each thread, I modify jmpbuf in two ways.
- I edit the PC and set it to the function pointer, so the program counter goes there.
- I also create my own stack and edit the SP to point to this stack
Thus, using my flow control structure, I can switch between flows and maintain the state of each of them, but I donβt know how to say when this function will be completed. When it's finished, I want to call the special function exit () that I have.
source share