Click here to Skip to main content
15,914,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: preemption for 16ms Pin
Nir sheffi24-May-07 2:45
Nir sheffi24-May-07 2:45 
GeneralRe: preemption for 16ms Pin
Roger Stoltz24-May-07 2:20
Roger Stoltz24-May-07 2:20 
AnswerRe: preemption for 16ms Pin
Randor 24-May-07 3:28
professional Randor 24-May-07 3:28 
GeneralRe: preemption for 16ms Pin
Roger Stoltz24-May-07 4:24
Roger Stoltz24-May-07 4:24 
GeneralRe: preemption for 16ms Pin
Randor 24-May-07 10:33
professional Randor 24-May-07 10:33 
GeneralRe: preemption for 16ms Pin
Roger Stoltz24-May-07 21:04
Roger Stoltz24-May-07 21:04 
GeneralRe: preemption for 16ms Pin
Randor 25-May-07 4:27
professional Randor 25-May-07 4:27 
GeneralRe: preemption for 16ms Pin
Roger Stoltz27-May-07 12:16
Roger Stoltz27-May-07 12:16 
Hello again David

Randor wrote:
Roger Stoltz wrote:
The calling thread enter a busy wait state and if the thread is preempted it probably won't run until a time ridiculously greater than the resolution set with ::timeBeginPeriod().


Are you actually implying that several milliseconds pass between thread preemtions? This is incorrect.


No, that's not what I'm implying and if I did it would be incorrect. Wink | ;)

What I meant was that ::Sleep() doesn't return unless the thread that called it is running. If the thread is preempted it won't run until it's given another timeslice which is approx. 10 msec under normal circumstances. This will happen if another thread is scheduled to run regardless of how ::timeBeginPeriod() works and what it affects. The resolution of the timer doesn't matter in this case.
If a developer desires to have a resolution close to 1 msec and in fact he gets a delay that exceeds 10 msec if the thread is preempted, I would consider it ridiculously greater than 1 msec.

If you still don't understand what I'm getting at, please read this[^] and this[^].

Slightly off topic:
To my knowledge the implementation of ::Sleep() is a "busy-wait" which means that it's continuously reading the time asking "are we there yet" until the desired time has passed.
This may have changed, but I still treat it as if it still is implemented as a busy-wait. It doesn't matter since I avoid calling ::Sleep().
Regarding the WM_TIMER message it's even worse: it won't even make it to the message queue. The WM_TIMER message is a low priority pseudo message that will be handled when all other pending messages have been handled. This means that even if the timer set with SetTimer() has expired multiple times before being handled, the message handler for the timer message will only be called once.

--
Roger


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown

QuestionAnyone know how I can install this addin? Pin
Stick^24-May-07 1:23
Stick^24-May-07 1:23 
AnswerRe: Anyone know how I can install this addin? Pin
David Crow24-May-07 3:12
David Crow24-May-07 3:12 
Questionlstrlen problem Pin
si_6924-May-07 0:36
si_6924-May-07 0:36 
AnswerRe: lstrlen problem Pin
James R. Twine24-May-07 0:49
James R. Twine24-May-07 0:49 
GeneralRe: lstrlen problem Pin
si_6924-May-07 0:52
si_6924-May-07 0:52 
GeneralRe: lstrlen problem Pin
James R. Twine24-May-07 1:00
James R. Twine24-May-07 1:00 
GeneralRe: lstrlen problem Pin
Naveen24-May-07 1:01
Naveen24-May-07 1:01 
QuestionIs my approach feasible? C++ Pin
C_Zealot24-May-07 0:26
C_Zealot24-May-07 0:26 
AnswerRe: Is my approach feasible? C++ Pin
Christian Graus24-May-07 0:50
protectorChristian Graus24-May-07 0:50 
AnswerRe: Is my approach feasible? C++ Pin
James R. Twine24-May-07 0:51
James R. Twine24-May-07 0:51 
GeneralRe: Is my approach feasible? C++ Pin
C_Zealot24-May-07 0:52
C_Zealot24-May-07 0:52 
GeneralRe: Is my approach feasible? C++ Pin
James R. Twine24-May-07 0:57
James R. Twine24-May-07 0:57 
GeneralRe: Is my approach feasible? C++ Pin
C_Zealot24-May-07 1:24
C_Zealot24-May-07 1:24 
GeneralRe: Is my approach feasible? C++ Pin
James R. Twine24-May-07 2:12
James R. Twine24-May-07 2:12 
GeneralRe: Is my approach feasible? C++ Pin
David Crow24-May-07 3:49
David Crow24-May-07 3:49 
GeneralRe: Is my approach feasible? C++ Pin
Michael Sadlon24-May-07 13:10
Michael Sadlon24-May-07 13:10 
QuestionHow to Get Selected Item Position In CListControl Pin
jannathali24-May-07 0:20
jannathali24-May-07 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.