Re: Sleep() issue



The code is for a Daq board (A/D converter).
Unfortunatlely the driver has no synchronization mechanism therefore I have
to continuously scan the driver to check what amount of data was transfered
to my buffer with DMA.
According to the scan rate and refresh period of my system the needed amount
of data is ready every 4ms.
The code is very simple and runs in a time critical priority thread:
while (1) {
count=get_scans_transferred()
while (count > buffer_size) { // buffer_size = room for 4ms of data
process_the_data(buffer_size)
count -= buffer_size
}
sleep(1)
}
This is a skeleton, the real code works dealing with the remaining data and
all the indexes management.

The accuracy of the duration of the sleep is not critical, it's here mainly
to avoid 100% of CPU load as with the driver synchronization functions.
Under XP Pro it works fine, but in XPE the duration of the sleep is 15ms
then we have the followin bahavior:
After the scans corresponding to 4ms acquisition tha data is processed.
The next call to function get_scans_transferred() is done only 15ms after,
then the buffer has collected data for 4 cycles (4x4ms = 16ms).
All the buffers are processed in the loop while (count>buffer_size).
After processing tha data a new value si sent to D/A converters and the
output looks like this:
t=0:new value - t+15ms later: updated value followed by 3 or 4 updated
values - t+30ms wait: updated_value ...
The operation in XP Pro is like this:
t=0new value - t+4ms updated value - t+8ms updated value - t+12ms....

Again, the Sleep(1) can wait for 1, 2, 3 or 4ms it doesn't matter, but not
more and not 15ms.
I don't need a real time OS because the 4ms period for the update is not
critical, it can be 4ms most of the time and sometimes 5, 6, 7, 8 and even
more.
No data is lost because of internal FIFO management and threads
communication.

Thanks
Senen


"KM" <konstmor@xxxxxxxxxxxxxxxx> a écrit dans le message de news:
OGP1HA7gHHA.4140@xxxxxxxxxxxxxxxxxxxxxxx
Senen,

I must admit I couldn't get what exactly you are trying to do and what
code you are testing.
Can you show up that piece of code you blame doesn't work the same way as
in XP Pro?

Anyway, you probably realize that XP (XP Pro, XP ) is not a real-time OS.
That means any "timeout" there is not promised by OS and OS itself may not
be deterministic. If you rally wanted to get precise numbers there you'd
probably go for a 3rd party solution that makes the XP(e) real-time
(TenAsys's INtime, ex-Venturcom's RTX).

What you want to do to get more statistic data on the issues is as
follows:
- bump up your "waiting" thread priority to highest or time-critical.
Especially make sure to run the piece of code in high priority where you
measure the timing (the place where you calculate it took 15ms instead of
2ms).
- use high-resolution timers by utilizing QueryPerformanceCounter API.

The above suggestion may not make sense for your application at all since
I had to guess about some things.
It would be more helpful it you could show us the code you are having
troubles with.

--
=========
Regards,
KM


Hi,

In my program I need to wait for a device for about 2ms. The accuracy of
the wait is not critical.
It works under Windos XP with a simple Sleep(2).
Under XPE the same program will wait for 15ms instead of 2ms.
Any value for Sleep() lower than 15ms will produce the same wait of 15ms.
The use of SetWaitableTimer produces the same effect.
How can I get a delai of few milliseconds in XPE?

Thanks
Senen




.



Relevant Pages

  • Re: Sleep() issue
    ... I also hope that you setting THREAD_PRIORITY_TIME_CRITICAL priority level ... XPe system. ... In my XP Pro system there is probably much more activity then the kernel ... I suppose you don't have the source code of the driver you are ...
    (microsoft.public.windowsxp.embedded)
  • Re: Sleep() issue
    ... Since you are running the thread in time critical priority I wouldn't expect the 10-15 jitter from the Sleepcall unless there ... Well, I suppose you don't have the source code of the driver you are referring to, right? ... Try to run the following code sniplet on your hardware and see if you get different results on XP and XPe: ... Also hope you test the same code under XPe and XP Pro on the same hardware. ...
    (microsoft.public.windowsxp.embedded)
  • Re: Printing with Leopard?
    ... I'm using an Epson Stylus Photo R340. ... printed successfully from both Photoshop CS3 and FileMaker Pro 9 -- I ... go further and click Driver the driver is grayed out and when I click Supply ...
    (comp.sys.mac.system)
  • Re: Target Analyzer Probe cannot find Intel PRO Wireless 2200bg mini-PCI card
    ... On XP Pro? ... installation with an executable provided with the driver. ... system recognized the card correctly and even, for some reason, ... installed the ethernet card. ...
    (microsoft.public.windowsxp.embedded)
  • Re: TV-Out problem
    ... >> I have an ATI Radeon 9800 Pro which has been having problems with the ... ATI has been less than helpful in trying to help me resolve ... >> interjects and says TV-Out quality is normally poor, I am aware of that, ... >> 9800 Pro drivers loaded, I must enable TV-Out from the driver control ...
    (microsoft.public.windowsxp.help_and_support)

Loading