avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] Win 32 port


From: Jan-Hinnerk Reichert
Subject: Re: [avrdude-dev] Win 32 port
Date: Tue, 17 Feb 2004 13:46:55 +0100
User-agent: KMail/1.5.4

On Tuesday 17 February 2004 13:28, Lou Cypher wrote:

> I'm not a Windows expert, but I was curious enough about this
> timing subject - - note: I'm using XP, an STK-200 like programmer,
> and never experienced troubles; left apart the Cadence licence
> manager (read: dongle driver), that needs to be shut down, and then
> I have to force three or four reading from device, before the
> system (or the driver?) releases the port (...)

Welcome to world of wonder and pain ;-)

> On 16 Feb 2004 at 17:56, Jan-Hinnerk Reichert wrote:
> > I believe that windows reads some (coarse) timer on sleep-entry
> > and than compares against it at each timer tick.
> > Let's say we have a Sleep(4) and a timer tick of 10ms. Than sleep
> > would return at the first tick appearing after the Sleep, which
> > could be almost immediately.
>
> Windows SDK, about Sleep(), says:
>   "This function causes a thread to relinquish the remainder of its
> time slice and become unrunnable for at least the specified number
> of milliseconds, after which the thread is ready to run."
>
> So, "at least" the required delay.

That's what they say and probably also what they mean. Nevertheless, 
it seems that at least Win2k doesn't always act like this.

> Note also that a Sleep(0) is meaningful, and that is the only case
> on which the function *could* return immediately:
>   "A value of zero causes the thread to relinquish the remainder of
> its time slice to any other thread of equal priority that is ready
> to run. If there are no other threads of equal priority ready to
> run, the function returns immediately, and the thread continues
> execution."

That's why I thought about including it.

> A Sleep(0) is infact a good way to give some time to other tasks,
> at least to refresh their state.
>
> I don't think I've seen mentioned, in this thread of discussion,
> the two functions QueryPerformanceCounter() and
> QueryPerformanceFrequency(), that are suggested in

This is the high-resolution counter I was referring to.

> I never used them, so I should make some tests before advising
> their usage, but I think that someone can directly stuff them in
> avrdude code and give them a try.

They are used in the CVS-code in usecPerfDelay() in "ppiwin.c". They 
seem to work very stable. The only problem is, that they might not be 
available on all hardware.

/Jan-Hinnerk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]