Thread View: comp.lang.pascal.delphi.misc
2 messages
2 total messages
Started by JJ
Tue, 14 Jan 2003 13:51
timebeginperiod doesn't succeed
Author: JJ
Date: Tue, 14 Jan 2003 13:51
Date: Tue, 14 Jan 2003 13:51
20 lines
1471 bytes
1471 bytes
Dear all, I'm trying to increase the timer resolution using the function timebeginperiod but this doesn't succeed at all. The resolution remains unchanged. I tested the following code : timebeginperiod(1); //This function returns Timerr_noerror t1 := timegettime; sleep(1); t2 := timegettime; timeendperiod(1); The difference beetween t2 and t1 remains always equivalent to 10; I also tried the same type of program with C++Builer but it doesn't succeed neither. I'm running under Windows XP and uses Delphi6. Any help will be appreciated JJ
Re: timebeginperiod doesn't succeed
Author: David Reeve
Date: Wed, 15 Jan 2003 01:27
Date: Wed, 15 Jan 2003 01:27
48 lines
3089 bytes
3089 bytes
JJ wrote: > > Dear all, > I'm trying to increase the timer resolution using the function > timebeginperiod but this doesn't succeed at all. The resolution > remains unchanged. I tested the following code : > > timebeginperiod(1); //This function returns Timerr_noerror > t1 := timegettime; > sleep(1); > t2 := timegettime; > timeendperiod(1); > > The difference beetween t2 and t1 remains always equivalent to 10; > I also tried the same type of program with C++Builer but it doesn't > succeed neither. > > I'm running under Windows XP and uses Delphi6. > > Any help will be appreciated > > JJ Sleep is a task scheduling component. A call to sleep, causes the calling thread to yield immediately AND be descheduled, and to remain descheduled for at least the time specified in the parameter you pass. Even if you set a small value for sleep, the OS will not get round to rescheduling it for at least one time slice, and, even then, it may not execute for perhaps a few more time slices depending upon what other tasks are running. For W98 where the time slice period is of the order of 20ms, and, whatever sleep period you use, you will see a typical jitter of some 50ms in a lightly loaded system. In W2K and XP, things are different. I assume the OS timeslice is smaller, and the scheduling seems to be handled more efficiently and less time jitter is encountered. Now, I suspect the multimedia timing functions get their precision by messing with the OS scheduling in the code between the call to timeBeginPeriod and timeEndPeriod. Maybe someone in the ng knows where this is documented? So what happens when you place a sleep within a multimedia timer section? It's anyones guess. My feeling is that you shouldn't use sleep in this way. Its a poor timer, slugs the main VCL thread if you use it there, but works brilliantly as an efficient means to control cpu consumption of slave threads. Dave
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads