Ok, I have to join the windows world ...

I've been in embedded/real-time for a long time. I've put-off having to learn the Microsquash programming world for a while. I now an submitting .... In any embedded O/S or kernel, the following is easy...

I've written utilities using VC++ (6.0) on and off, mainly repackaging binaries for CRC's, Hex/S formats etc... I'm running on XP pro.

I need to make a "continuous" calculation, say 10 -> 100 times a second.

The calculation is not compute intensive.

I want to "sleep" the process/task/thread for the appropriate time to achieve the required frequency... I do not want to do busy-waiting in a loop, I have to free up the CPU bandwidth for other stuff...

I know Windows is NOT real-time or deterministic by any stretch of the imagination... It's not required for the simulation I'm doing...

so .... the pattern is simply for now, compute; print; sleep ->

eventually I'm going to pass this compute result to another "process" running on the CPU -> another cosole instance is preferred.

This is a CONSOLE app... There appears to be a POSIX interface that may allow me to do what I need, is there any other API I can use that will allow me to remain in a console APP? or do I have to submit myself to re-learning the windows proc loop to use windows API's for this??? Hmmm, just remembered a book on windows/NT threading I think...

BUT, I come here first for the wizened sages who have gone thru learning window "re-terminology" for all we learned in school (the way back machine here... Windows was still 16 bit when I was in school....)

TIA,

-Dan

Reply to
packer44
Loading thread data ...

Why not write it as a cygwin app, and not deal with any Windows APIs at all? :)

Reply to
larwe

Why not use Linux instead. It's dead easy.

IAn

Reply to
Ian Bell

snip

If it is that simple you can use the Sleep() function that takes the number of milliseconds as a parameter.

This is probably not the right ng for this kind of questions, unless you want people to express their sympathy ;)

Reply to
Lanarcam

Thanks gents, I came here because I AM an embedded developer... I used SleepEx() ...

Put this one to bed...

Thanks,

-D

Reply to
packer44

No need for a message loop.

In a console application, at the end of your calculations, simply call the WaitForMultipleObjects with no handles but with a suitable timeout parameter. While the timeout parameter is in milliseconds, the actual resolution is 10 ms (or 15.625 ms for multiprocessor kernels).

Paul

Reply to
Paul Keinanen

I have in the past compared Windoze programming to old text-based adventure games -- you don't have everything you need, but if you dig around a little, find the important bits, and invoke the magic incantation, you can make what you need.

Sleep(10) should sleep for close to 10 ms for you. About 10 ms granularity. Certainly not deterministic.

Look up memory-mapped shared files. They're not hard to use. At a PPOE, I created a bunch of inter-process communications primitives based on them. Things like a deque, where the consumer could optionally block until data became available and the producer could optionally block until the queued data was extracted. It's the blocking stuff that can get strange to someone used to RTOS and multitasking kernels...

Bill Gates thought 640k oughtta be enough for anybody back when I was in school.

Regards, -=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen

While you may be correct for normal thread priority, my experience shows 1ms granularity in RT thread.

Also one can achieve very low latencies in RT thread priority. I have implemented a software LIN slave nodes few years back for my employer by receiving buffer overrun (SOF) and responding back at 9600. There was 6 such threads running on 6 UARTS (FIFOs off) each emulating 4 nodes. The response latency was about 200us and when putting entire system under 100% stress (launching few memory and processor hungry applications at the same time), oscilloscope shown the latency increase by another 100us.

For the master units that counted as "real-time" response.

Of course I am talking about USER mode. That means about 50us expense with each call to a driver stack on P4 / 2GHz

Reply to
rziak

I haven't seen this documented anywhere, but it appears (at least on NT4) that if _any_ process calls timeBeginPeriod with 1 ms resolution, the WaitForSingle/MultipleObject and Sleep indeed works with 1 ms granularity on all processes.

I have done some thread wakeup tests with 100-500 MHz processors and the jitter appears to be within a millisecond or two.

However, did you measure the worst case latencies ? These can be quite hard to see on an oscilloscope.

In my experiments, I observed some rare 10-20 ms peaks at time to time when there was a lot of other activity on the system.

My colleague was using a system on which I had my cycle time monitoring running. He was quite amazed, when the following day when I told him when he had taken a break for smoking outside, by examining the distribution of the cycle times :-).

Paul

Reply to
Paul Keinanen

You can use Sleep() or CreateWaitableTimer + WaitForSingleObject. Take a look at MSDN for more help there.

ttyl,

--buddy

Reply to
Buddy Smith

I am not sure if this is documented or not, this was only my experience.

You are right, my values are just visual readings from scope. No worst case measurement.

As far as I remember, there was very little jitter with no activity on the system and about 100us average with 100% system load. What thread priority did you use ?

Roman

Reply to
rziak

You might want to repost this to microsoft.public.vc.* newsgroups.

Also, you could get a Unix type interface on Windows. Checkout the following link:

formatting link

-- EventStudio System Designer 2.5 -

formatting link
Sequence Diagram Based Real-time and Embedded System Design Tool

Reply to
EventHelix.com

Wow, so could this package be used to write applications that compile under Windows and Mac OSX with little changes? Does this package include GUI related APIs or sound card APIs?

I have to write a file translation utility for both Windows and MAC OSX. I am looking at WxWidgets but I am concerned about the whole GPL thing since we have some proprietary code involved that cannot be made public.

-howy

Reply to
howy

In article , howy writes

What package?

If you are going to use the broken google system to interface to Usenet please set it up properly. You need to quote the message you are replying to.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ chris@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Reply to
Chris Hills

Please quote properly. I assume you mean wxWidgets.

According to their website

formatting link

---------------------------------------------------------------------- wxWidgets is currently licensed under the "wxWindows Licence" pending approval of the "wxWidgets Licence" which will be identical apart from the name.

The wxWindows Licence is essentially the L-GPL (Library General Public Licence), with an exception stating that derived works in binary form may be distributed on the user's own terms. This is a solution that satisfies those who wish to produce GPL'ed software using wxWidgets, and also those producing proprietary software.

----------------------------------------------------------------------

So, you can make a product/program/etc that uses wxWidgets and you do not have to release any source code.

Please read the full license for more details.

ttyl,

--buddy

Reply to
Buddy Smith

SFU for Windows does support most Unix APIs. I don't think it support GUI interfaces.

wxWidgets is a better choice for GUI applications.

-- EventStudio System Designer 2.5 -

formatting link
Sequence Diagram Based Real-time and Embedded System Design Tool

Reply to
EventHelix.com

I keep coming back to wxWidgets in my search for the solution to my problem, but I read on their group that it's not for the beginner C++ programmer. I am just an embedded C guy and all the rest of us here are swamped with too much to do.

Do you folks have any good suggstions for where to post a request for a consultant who has experience with wxWidgets? I have tried a few of the .jobs groups already.

We need someone to write a little GUI based WAV file conversion program that runs on a PC and a MAC. The coversion process will use C code that is already in another embedded product to batch convert our proprietary audio files into a standard WAV format.

If anyone knows of someone who is looking for a few weeks worth of work in this area, please have him/her contact me.

thanks,

-howy snipped-for-privacy@zaxcomBOOSPAM.com (remove the capital letters from this address)

Reply to
howy

This has me puzzled. Why would you want to use a GUI for a tool explicitly created for batched work? Command-line programs are better for batches in just about every possible aspect. The worst possible disadvantage I can think of would be that some non-technical users might be scared a bit. For a shop working on embedded systems, I honestly can't see how that could be a major issue. Heck, these days even the Macintosh crowd has understand that command line windows can be useful things!

Then, if you still think you need a GUI, you can always develop it as a separate "shell" program in whatever language anybody happens to know or like (C++, Java, Pascal/Delph, Python, Tcl/Tk, VisualBasic, Javascript --- anything goes). The GUI shell would then execute the simple command-line program as a background process, to do the real work. Depending on how you do the command-line program, there may even be GUI shells that can do this for you. I.e. it could reduce to something as simple as "open a file system explorer, mark the relevant files, then drag'n'drop the whole bunch onto the green 'C' on your desktop".

As an additional benefit, you wouldn't have to worry so much about licensing issues with the GUI toolkit, either, as the noqn-shareable code never gets linked to any of the GUI stuff.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

I agree with other posters that you don't want a GUI for your batch program - write it as a simple command-line C program that can compile on anything, and if you must have a GUI wrapper, make it separately. Remember that just because you want it to run on Windows as well as

*nix, doesn't mean you have to follow the traditional Windows insanity of writing one huge GUI program to do everything - modularise your problem into sensible parts.

If you are still looking for a cross-platform GUI toolkit that works nicely with C rather than C++, try GTK.

Reply to
David Brown

I agree. I already have a command line program for WinXP to do the job but customers are complaining. Half the intended users of this program are not computer savvy at all.

I have considered using a GUI wrapper to call the command line program, but I am not sure how to have the GUI extract the real time status/output of the command line program in a reasonably neat way. I have been told there are ways to capture stdout from a spawned EXE program from Java, but I have yet to see if this is only a capture of the program after the program has finished. If I can find a way to capture real time status info from the cmd line program I will do it the way you suggested.

Most of the time this program will be processing at least 3GB of data and in several instances will need to convert an entire hard drive's worth of audio data in a shot, so feedback is important (at least in the sense of a meaningful pacifier).

-howy

Reply to
howy

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.