setcontext always starts from function line
I am implementing a userthread library. When I try to swap the context
when the yield is called, the swapped function is always starting from the
first line. The program counter is not updated I guess. For Example,
consider there are two Threads, say
T1: {
printf("Inside T1. Yielding to Other \n");
ThreadYield();
MyThreadExit();
}
T2: {
ThreadCreate(t1, 0);
printf("Inside T2. Yielding to Other \n");
ThreadYield();
}
In this case, when I use the setcontext/swapcontext, always the thread
starts from the line 1. So many threads are created and it goes to a
infinite loop. Can anyone tell me what is going wrong
No comments:
Post a Comment