Board index » cppbuilder » How to run my app in single processor mode?
Christer Strandh Aragon
![]() CBuilder Developer |
Christer Strandh Aragon
![]() CBuilder Developer |
How to run my app in single processor mode?2004-06-16 10:08:13 PM cppbuilder81 Hi, I have problem with hyper-threading and dual processor mode with my BCB6 application, how can I make my application run in single processor mode? I have tried the following code in my main form. Perhaps this only makes the main form run in single processor mode. void __fastcall TMainForm::FormCreate(TObject *Sender) { SetProcessAffinityMask(Handle, 0); .... } Best Regards, Christer Strandh |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2004-06-17 12:40:31 AM
Re:How to run my app in single processor mode?
"Christer Strandh Aragon" < XXXX@XXXXX.COM >wrote in
message news:40d053da$ XXXX@XXXXX.COM ... Quotevoid __fastcall TMainForm::FormCreate(TObject *Sender) QuoteSetProcessAffinityMask(Handle, 0); They two are not the same thing. You should be using GetCurrentProcess() instead of the form's Handle property. Also, you should be calling GetProcessAffinityMask() first to determine the mask that is available to begin with, and then remove the unwanted bits from it before then passing it back to SetProcessAffinityMask(). Gambit |
Christer Strandh Aragon
![]() CBuilder Developer |
2004-06-18 05:11:22 AM
Re:How to run my app in single processor mode?
Ok thanx för the input.
Sorry for my ignorance, but I cant get it to work, I put the SetProcessAffinityMask code in the project .cpp file like this... My app. hang when trying to start. Not sure what time to execute SetProcessAffinityMask() after or before run? have tried both. Running BCB6 P4 with hyper-threading... WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { Application->Initialize(); SetProcessAffinityMask(GetCurrentProcess(), 0x001); Application->CreateForm(__classid(TMainForm), &MainForm); Application->Run(); ) //Christer Quote>void __fastcall TMainForm::FormCreate(TObject *Sender) {smallsort} |
Robert Ehteshamzadeh (Borland QA)
![]() CBuilder Developer |
2004-06-24 07:37:56 AM
Re:How to run my app in single processor mode?
From my understanding, the process ID would be determined before the
entry point (WinMain), and will remain the same until the process terminates, so you should be able to call GetCurrentProcess as the first statement after WinMain as far as sequence goes, it would be : WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { SetProcessAffinityMask(GetCurrentProcess(), 0x001); Application->Initialize(); ... Christer Strandh Aragon wrote: QuoteOk thanx för the input. |