Can anyone tell me how to insert a function call (say Yield() ) at random places inside a C function , so that each time the code is run , Yield() gets called from different parts of the code ?
I am faced with such a requirement as I'm using 2 threads in a cooperative threading environment , where unless the running thread yields the processor explicitly , the other (waiting) thread cannot start running. I don't want to place the Yield() call at a single point , since that makes the thread sequence deterministic. Without rewiring the entire environment (from cooperative to pre-emptive) , this is the only solution I can think of in which Thread_1() makes the Yield() call at random places inside it, allowing Thread_2() to take over.
Any insights into a different solution achieving the same end-goals is also welcome!