Click to See Complete Forum and Search --> : Synchronization: Finish before re-scheduling...
Teddybare
November 18th, 2004, 04:12 PM
I want to finish a particular task (a block of code) before the scheduler kicks in. How can this be done.
What I'm trying to accomplish is to transmit data to an external device and do it without getting interrupted by the scheduler. If scheduler places my other thread for execution while tx, the tx will not be succesful.
Regards,
Ted
MikeAThon
November 18th, 2004, 05:08 PM
You can temporarily SetPriorityClass of the process to REALTIME_PRIORITY_CLASS and SetThreadPriority to THREAD_PRIORITY_TIME_CRITICAL, but this is dangerous and not recommended. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/scheduling_priorities.asp
Basically, Windows is simply not a real-time OS, and there's very little you can do to stop it from pre-empting your thread/process if it really wants to.
Mike
kuphryn
November 19th, 2004, 12:43 AM
In general, there is no guarantee your thread will not lose CPU. The issue, as mentioned already, is that windows is not a real-time OS. Given your thread is set to a real-time priority, another thread might have the same priority too.
Kuphryn
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.