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: Lou Cypher
Subject: Re: [avrdude-dev] Win 32 port
Date: Tue, 17 Feb 2004 13:28:33 +0100

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 (...)

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.
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."

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
  http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/dndllpro/html/msdn_realtime.asp
where they say:
  "For IntelĀ®-based CPUs, the resolution is about 0.8 microseconds."

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.
Following the SDK documentation, QueryPerformanceFrequency() gives the actual
"counts per second" resolution (or Hz), and the QueryPerformanceCounter() the
current counts -- I wouldn't trust it really gives 0.8 us resolution ;) but
setting a while() loop, or similar, will only tell.

If any of you already tried them, without success... well... keep my dime ;)

Lou






reply via email to

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