Click here to Skip to main content
15,910,603 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: the more leaks...... Pin
John R. Shaw25-Oct-05 10:29
John R. Shaw25-Oct-05 10:29 
GeneralRe: the more leaks...... Pin
valerie9925-Oct-05 10:51
valerie9925-Oct-05 10:51 
QuestionRe: the more leaks...... Pin
David Crow26-Oct-05 3:25
David Crow26-Oct-05 3:25 
GeneralRe: the more leaks...... Pin
krmed26-Oct-05 5:12
krmed26-Oct-05 5:12 
QuestionRe: the more leaks...... Pin
David Crow25-Oct-05 10:32
David Crow25-Oct-05 10:32 
Questionguarantee to run in a certain period Pin
LeeeNN25-Oct-05 8:14
LeeeNN25-Oct-05 8:14 
AnswerRe: guarantee to run in a certain period Pin
Roger Stoltz25-Oct-05 9:03
Roger Stoltz25-Oct-05 9:03 
AnswerRe: guarantee to run in a certain period Pin
Joe Woodbury25-Oct-05 12:01
professionalJoe Woodbury25-Oct-05 12:01 
First, the article referred to by Roger is out of date and contains some errors [this was edited to make it more clear that I was talking about the article Roger linked to and that I am not saying the article is full of errors. It is not.] Most importantly, a thread does not have to run for it's entire quanta (or time slice) and in reality, most do surrender most of it. Second, W2K and XP use a different resolution on timers [Edit: this is misleading. I meant to say that W2K and XP are different than NT, not necessarily from each other. W2K, for example, allows much more flexibility over the quantum table: One significant change to W2K
http://www.sysinternals.com/Information/Windows2000Quantums.html[^]]

The article is [very] right that that Windows is NOT a real time OS. It cannot guarantee that a thread will execute at a set time unless you add specialized hardware and drivers. However, it generally responds within 1ms of your ideal--even WM_TIMER is pretty accurate if you're talking 50ms. [I stand by this; note the phrase "in general."]

Take a look at SetWaitableTimer for one option.

Another is to use WaitForSingleObject and use a timeout that you calculate using GetTickCount() [Edit: QueryPerformanceTimer() is a better choice] with each loop based on how much time the operation of the loop took. I've used this for applications where I needed behavior like SetWaitableTimer() but was severely limited on the number of handles I could use.

Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke


-- modified at 12:20 Wednesday 26th October, 2005
AnswerRe: guarantee to run in a certain period Pin
Roger Stoltz25-Oct-05 22:56
Roger Stoltz25-Oct-05 22:56 
GeneralRe: guarantee to run in a certain period Pin
Joe Woodbury26-Oct-05 0:22
professionalJoe Woodbury26-Oct-05 0:22 
QuestionDesign advice needed Pin
Keith Vitali25-Oct-05 8:03
Keith Vitali25-Oct-05 8:03 
AnswerRe: Design advice needed Pin
Achim Klein25-Oct-05 8:31
Achim Klein25-Oct-05 8:31 
AnswerRe: Design advice needed Pin
John R. Shaw25-Oct-05 9:03
John R. Shaw25-Oct-05 9:03 
GeneralRe: Design advice needed Pin
Keith Vitali26-Oct-05 9:15
Keith Vitali26-Oct-05 9:15 
AnswerRe: Design advice needed Pin
Joe Woodbury25-Oct-05 12:06
professionalJoe Woodbury25-Oct-05 12:06 
AnswerRe: Design advice needed Pin
User 58385225-Oct-05 17:21
User 58385225-Oct-05 17:21 
QuestionMalloc / Free problem Pin
Jader8925-Oct-05 6:45
Jader8925-Oct-05 6:45 
AnswerRe: Malloc / Free problem Pin
Roger Stoltz25-Oct-05 7:01
Roger Stoltz25-Oct-05 7:01 
GeneralRe: Malloc / Free problem Pin
Jader8925-Oct-05 7:31
Jader8925-Oct-05 7:31 
AnswerRe: Malloc / Free problem Pin
Maximilien25-Oct-05 7:10
Maximilien25-Oct-05 7:10 
GeneralRe: Malloc / Free problem Pin
Jader8925-Oct-05 7:33
Jader8925-Oct-05 7:33 
QuestionRe: Malloc / Free problem Pin
David Crow25-Oct-05 7:27
David Crow25-Oct-05 7:27 
AnswerRe: Malloc / Free problem Pin
Jader8925-Oct-05 7:34
Jader8925-Oct-05 7:34 
QuestionRe: Malloc / Free problem Pin
David Crow25-Oct-05 9:27
David Crow25-Oct-05 9:27 
AnswerRe: Malloc / Free problem Pin
Jader8925-Oct-05 9:34
Jader8925-Oct-05 9:34 

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.