Hope that this is right forum for my question.
i am experimenting with native Win32 multithreading and trying to force currently executing to thread to relinquish its cpu time by calling Win API function sleep() with 0 argument.When sleep(0) is called from within thread function then currently executing thread will be swapped and put in wait queue.
One interesting question arises which is related to exact moment of quantum interval when the execution is postponed and how to control it programmatically.If new thread is created from within the main function thread and that new thread has priority rised to high and it is scheduled to run immediatly after creation so how (inside thread's function) or better when sleep(0) call will be executed in order for example to stop the execution after 1/2 of quantum expires.I am thinking about the inserting call to sleep at begining oof the function thread and verifying it in disassembly so I could be able to theoretically postpone the execution as a function of location(at address space) of call instruction.By insering some job/task or calculation which will keep thread busy for quantum period ~30ms and insering inside loop call to sleep function I can postpone the execution of thread before it quantum expires.
Does anyone have some experience with this?
Source code is included.
Thanks in advance