Strange problem doing infinite while loop in EXE
I ran into an unusual issue on Windows CE:
Run 3 EXE
1) At first the exe does some work every 8 minutes if no exit event is specified. 2) The second exe does some work every 5 minutes unless an exit event is specified. 3) The third exe while loop is running, and during the loop it does some work at random times. This while loop continues until the exit event occurs.
This completion event is now a global event and can be signaled by any process.
Problem When I run First exe it works fine, Run the second exe it works fine, run the third exe it works fine
When I run all exes, only the third exe is executed, and no instructions are executed on the first and second.
As soon as the third exe finishes, the first and second runs start being processed. Could it be that the while loop in the third exe takes all cpu cycles? I haven't tried to put Sleep, but I think it might do some tricks. But the OS should give a processor to all processes ... Any thoughts ???
source to share
(Out of memory) Processes in Windows CE run to completion if there are no processes with a higher priority, or they start for their temporary chunk (100ms) if there are other processes with equal priority. I'm not sure if Windows CE gives a process with an active / foreground window a little priority (like Windows does) or not.
In your situation, the first two processes are hungry on CPU time, so they never start until the third process finishes. Some ways to solve this problem:
- Make the third process wait / block on some multiprocessor primitives (mutex, semaphore, etc.) and a short timeout. Using WaitForMultipleObjects / WaitForSingleObject etc.
- Make a third wait process, using a call to sleep every time the loop runs.
- Boost the priority of other processes, so when they need to start, they will abort the third process and actually start. I would probably call the least frequently named process the highest priority of the three processes.
Another thing to check is that the third process does indeed complete its tasks on time and does not bind the CPU to do its job normally.
source to share