|
Yes, use lineGenerateDigits()
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Can VS7 optimize compilation for a dual-processor machine?
I have a dual-processor machine here, and I have some analysis code that completely peaks out performance - but between the 2 processors, it's only 50% system performance.
Now I'm an assembly programmer, so I don't mind doing some low-level coding to hand-optimize it, but I have this horrible feeling that WinNT is going to shout at me if I try to take it over.
Any thoughts? Do I need a new compiler?
J
|
|
|
|
|
Just from the top of my head.
If you have only one thread, I think a second processor is useless. Having multiple processors is usefull only for multi-threaded apps or when running multiple processes.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
I'm not 100% sure, but I'd say Windows OSs do not distribute a given process execution among different processors --they only assign processes across processors to balance the load. So to take advantage of a 2-CPU machine in a single program, you should be launching processes from the app, much the same ay as you would with threads.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hmmm. This is my understanding as well... So it's going to be a major pain in the ass to share the data between processes.
J
|
|
|
|
|
It is not that hard. Use shared data segments for accessing and named mutexes for synchronization.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hmmm. I think they (Windows OSs) do distribute thread among CPUs. Take a look at SmartHeap SMP (http://www.microquill.com), it seems to talk about heap allocation with multiple processors.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
Ummm... Yeah, you're right. Even NT 4.0 allowed for threadwise multiprocessor support. It is stated very clearly here[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, but you don't get better performance from a single thread. You'll just see, in the task manager, that both cpu's uses about 50% each
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
You can use the API SetThreadAffinityMask to tell WinNT which processors a thread can run on. So if you've got two threads and two processors, make two calls to SetThreadAffinityMask giving it each thread handle and each different processor affinity mask. Like so:
<br />
SetThreadAffinityMask( GetCurrentThread(), NOT_SURE_HOW_TO_GET_THIS_VALUE );<br />
<br />
SetThreadAffinityMask( GetCurrentThread(), NOT_SURE_HOW_TO_GET_THIS_VALUE_BUT_IT_WILL_BE_DIFFERENT_THAN_ABOVE_VALUE );<br />
<br />
There's also SetThreadIdealProcessor, but I don't think that would be super reliable, as it is only a request.
Chris Richardson
|
|
|
|
|
As others have said, you need a thread per processor to get better performance...
If you play around with the cpustress.exe utility you can see it very clearly
You can find cpustress in the platform sdk's bin folder
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Windows balances threads, not processes. A single process, with multiple threads, will be balanced by the O/S. Of course, like any multithreaded application, you have to make sure that thread arbitration doesn't bog things down.
Gary R. Wheeler
|
|
|
|
|
In my application, I have lots of top level windows. The only styles I set are WS_EX_TOOLWINDOW (extended style) and WS_POPUP (normal style). That makes border-less windows that do not add a button on the task bar.
I have a registered a hotkey to show all the windows from anywhere. It works perfectly.
What I am trying to do now is find a way to send those windows to the bottom of the Z order, behind all other windows and the give the focus to the window that had the focus before the windows where shown.
SetWindowPos with HWND_BOTTOM (and SWP_NOSIZE | SWP_NOMOVE) should do that trick, but it doesn't. The function is called and returns a success, but the windows stay in from. I tried not setting the WS_EX_TOOLWINDOW style but it doesn't change anything.
I have looked for HWND_BOTTOM (and MFC's wndBottom) in the message board, on CodeGuru's message board and on Google. I saw someone with the same problem, but there was no reply. It was either a copy-paste of the doc with the message related to HWND_TOP, or the doc itself.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
Try setting the desktop as the parent of your top level windows (no success guaranteed ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yeah, I know about GetDesktopWindow but I always thought it was the same as specifying null as the parent.
By the way, no luck, it didn't work.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
(Another crazy idea) Have an invisible dummy window as the parent of the popups and do the SetWindowPos on this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yeah, that's a good idea. But it still doesn't explain why it doesn't work right now.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
When it comes to Windows programming, often one has to settle for workarounds instead of explanations
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a problem using CRecordSet and CDatabase in W2000 with a restricted-permission user. CDatabase::Open return with the error: "Cannot read the registry key SOFTWARE\ODBC\ODBC.INI\ ", but with regedit this key is visible. Where is the problem?
Someone can help me?
thanks
|
|
|
|
|
Greetings all (first post on CodeProject),
Have a fairly simple Dialog based application (modal) which
calls another class (Worker) to perform a list of tasks. Dialog box
class has a simple method for setting the window text of a
CStatic, all works fine (window text is updated correctly
by Worker class until Worker class makes a ShellExecuteEx call
to run another exe. Upon return from the ShellExecuteEx call
the CStatic window text can't be updated, the calls are there
to change the text, it just doesn't work, I've tried a few combinations
of SetForeGroundWindow(), ShowWindow (SW_HIDE/SW_SHOW), Invalidate()
and so on... all to no avail.
Read around various sites and forums with no real success.
Code snipper follows:
if (ShellExecuteEx(&stShellInfo)) {<br />
<br />
int nResult = (int)stShellInfo.hInstApp;<br />
if (nResult >= 32) {<br />
theApp.SetSubProgressMessage("SHELLINFO hInstApp = process successful");<br />
}<br />
else {<br />
theApp.SetSubProgressMessage("Process failed");<br />
}<br />
<br />
WaitForSingleObject(stShellInfo.hProcess, INFINITE);<br />
<br />
CloseHandle(stShellInfo.hProcess);<br />
<br />
CWnd *pWndPrev, *pWndChild;<br />
if (pWndPrev = CWnd::FindWindow(NULL, _T("Progress"))) {<br />
pWndChild = pWndPrev->GetLastActivePopup();<br />
if (pWndPrev->IsIconic()) {<br />
pWndPrev->ShowWindow(SW_RESTORE);<br />
}<br />
<br />
<br />
pWndChild->ShowWindow(SW_HIDE);<br />
pWndChild->ShowWindow(SW_SHOW);<br />
}<br />
...
No message after the "process successful" message are displayed.
Any suggestion/help/info would be greatly appreciated.
BTW, it's probably obvious that I'm new to MFC.
MTIA.
Chris
|
|
|
|
|
Your application sleeps in WaitForSingleObject call until the child process finishes. You need to handle application message queue using PeekMessage. Search in MSDN Library for Q74795 KB article "Using PeekMessage() Loops in a Dialog Box" for details.
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks for the help Pavel, much appreciated.
|
|
|
|
|
Read up on the article you posted, also read about the
TranslateMessage and DispatchMessage functions but still
unclear as to where and how I would implement the
PeekMessage calls.
Once again, many thanks for the help.
Chris
|
|
|
|
|
Use the WaitForSingleObject call in a loop with timeout set to reasonable short time (100 ms?) and when it doesn't return WAIT_TIMEOUT, break from the loop. If it does, pump the messages using PeekMessage and continue looping.
Pavel
Sonork 100.15206
|
|
|
|
|
Hi to All
I want to ask u that how can i make a round shape window or elliptical shape window using MFC.Please explain with some Code
Thanks
Inam
|
|
|
|