OS/2, eCS & ArcaOS - Technical > Programming
Stopping CPUs
Doug Clark:
I am trying to stop/disable cpus programmatically. I am calling
DosSetProcessorStatus(cpuNum,0);
Which returns with an error message. However the cpu is not turned off or stopped. Is there something else I have to do in addition to calling this function, or should I be calling another function? Or is it even possible to stop one or more cpus after boot up.
Thanks in advance
ivan:
Why would you want to do that? If it is a multi core CPU you no can do unless you open the box and physically remove the CPU.
Doug Clark:
There are some OS/2 programs, and some Win-OS/2 programs, that do not run well, or at all, when multiple CPUs are enabled, but will run when the system is limited to using a single processor. The AOS installer is apparently one of those: the installer program turns off multiple CPUs when it starts.
You can limit the number of CPUs, or processors, used by AOS with the /MAXCPU=1 parameter to the PSD=ACPI.PSD line in CONFIG.SYS. However this must be done on boot up and that limitation, or setting, remains in effect until another reboot. I believe this is what the AOS installer does.
It would be nice to be able to turn off and turn on processors as needed. That way I could turn off all the processors except the main one when running one of those programs, and turn the additional processors back on when the program is done running - without rebooting. Which is what DosSetProcessorStatus() is supposed to do.
I should add here that I am testing this on a system with a Ryzen 5 processor and the compatibility/legacy support enabled. I have not tried this on a system with an Intel processor yet.
I should also add that DosSetProcessorStatus() and DosGetProcessorStatus() appear to work, in that they return an error code if I try to set or get the status of a processor that doesn't exist - like processor 7 on my 6 processor Ryzen. But they don't actually turn off any processors, according to the CPU meter.
Jochen Schäfer:
Essentially, you want something like the CPU affinity feature in Windows. Correct?
Doug Clark:
Jochen - a similar concept, although for perhaps different reasons. Quoting from a part of the SMP reference document:
--------------------------------------
...
These compatibility requirements apply only to multithreaded applications, and therefore do not apply to DOS and WINOS2 applications. However, you are strongly encouraged to write 32-bit multithreaded applications for better performance and portability on OS/2 Warp Server for SMP.
Given that there is the possibility of some set of applications which may use one of these techniques, OS/2 Warp Server for SMP provides a mechanism whereby these multithreaded applications can execute in UP mode. Only one thread of that process would be allowed to execute at any given time. That thread could execute on any one of the processors. A utility is used to mark the EXE file as uniprocessor only. OS/2 forces the process to run in the uniprocessor mode when the loader detects that the EXE file has been marked as uniprocessor only. See View and Set Program Type For Executable File (MARKEXE).
--------------------------
Using MARKEXE in OS/2 looks to be somewhat similar to setting processor affinity in Windows. However I question whether whether OS/2 is honoring the uniprocessor setting in the executable.
I do know that using the /MAXCPU=1 parameter with PSD=ACPI will allow some Win-OS/2 programs to run correctly that will not run without the /MAXCPU=1 setting. So perhaps that parameter is doing more than addressing "one of these techniques" the above quote is referencing.
The "one of these techniques" from the quote are basically some CPU instructions and techniques that wont work with multiple CPUs. The processor affinity in windows seems to be aimed at performance issues rather than compatibility issues - some programs run faster with fewer processors.
Navigation
[0] Message Index
[#] Next page
Go to full version