oferf@shum.Huji.AC.IL (ofer faigon) (06/06/89)
Hello, I have a problem regarding process priorities in Windows/386: I have two programs - one is a Windows aplication (W), the other a DOS application (D). I want to run them together, with W visible and covering the whole screen and D in the background. At certain times (T) D has to get all or most of the CPU cycles, without popping into view. I tried using several methods: 1 - use the 386 API function, whose description I found in Online, to terminate the current time-slice every time W gets the CPU during T. 2 - call SetPriority(GetProcessId(),...) in W at the beginning/end of T. 3 - call WaitMessage in W during T. 4 - use Yield(). (1), (3) and (4) seem to be doing absolutely nothing, based on run time measurements. (2) hangs the machine - no response to mouse or keyboard events. I played with this a little and found that the hanging occurs whenever there is ANY DOS applic in the bacground, but not when there are only Windows applics. I am using the run-time environment of Windows/386 2.11, but W is linked with the library of an older SDK (I don't have it here now; I think it is ver 2.1) What can I do? Thanks, Ofer. P.S. I do not have easy access to Online; Please do not send me there... - Ofer Faigon TEL: +972-2-669-834 MAIL: P.O.B 7347, Jerusalem 91072, ISRAEL BITNET: oferf@HUJINIX CSNET & INTERNET: oferf@shum.huji.ac.il
pdavid@polyslo.CalPoly.EDU (Paul C. David) (06/06/89)
oferf%shum.UUCP@humus.Huji.AC.IL (ofer faigon) writes: >I have two programs - one is a Windows aplication (W), the other a DOS >application (D). I want to run them together, with W visible and >covering the whole screen and D in the background. >At certain times (T) D has to get all or most of the CPU cycles, >without popping into view. Try a method outlined in the Petzold book. Somewhere he writes an application requiring a background process. He uses PeekMessage to determine that nothing is in the message queue, and when it is empty, he dishes off cycles to the background process (D). -- Paul C. David pdavid@polyslo.CalPoly.EDU California Polytechic State University, San Luis Obispo "..And they said that the Commodore would stand up to everything" -from "Earthgirls are Easy"
michaelt@microsoft.UUCP (Michael Thurlkill 1/1029) (06/08/89)
In article <11737@polyslo.CalPoly.EDU> pdavid@polyslo.CalPoly.EDU (Paul C. David) writes: >oferf%shum.UUCP@humus.Huji.AC.IL (ofer faigon) writes: >>I have two programs - one is a Windows aplication (W), the other a DOS >>application (D). I want to run them together, with W visible and >>covering the whole screen and D in the background. >>At certain times (T) D has to get all or most of the CPU cycles, >>without popping into view. > Try a method outlined in the Petzold book. > Somewhere he writes an application requiring a > background process. He uses PeekMessage to > determine that nothing is in the message queue, > and when it is empty, he dishes off cycles to the > background process (D). Actually, I don't know if this will solve your problem. PeekMessage will work great if you have two Windows apps. If appA uses GetMessage and appB uses PeekMessage, then appB can get all processor time until appA gets a message. So, if you are writing D, the best thing to do would be to make it Windows app, iconize it, and use a PeekMessage loop to poll the queue. However, if this HAS to be a dos app (not something you wrote) then about the best you will do, in the current manifestation of Windows/386 is to have your foreground Windows app call GetMessage. This way, the windows app grabs the processor only when it gets a message, and the background dos app will get a few more time slices. BOOL PeekLoop() { MSG msg; while(TRUE){ if(!PeekMessage(&msg,NULL,0,0,PM_REMOVE)) doSpecialStuff(); else { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } } } Mike Thurlkill Disclaimer: These thoughts are mine, and only mine. These thoughts should in no way be mis-construed as being correct or attributable to anyone but me.