cd_setcpu
Posted: Tue May 03, 2016 9:16 am
Roger,
I am using your example and have for a while. A new client has 16 cpu's`Can that be handled by increasing the vars.
LOCAL nHnd := 0 // file handle
LOCAL nLast := 1 // last CPU used
LOCAL aSet := {} // processor array
LOCAL nSet // default new bitmask
LOCAL i // counter
//DEFAULT cFile := GetEnv('WINDIR') + '\Temp\SetCpu.Smp'
DEFAULT cFile := vdrive+"\oiswin\SetCpu.Smp"
DEFAULT nCPU := 15
// 15 = 4 CPUs
// 7 = 3 CPUs
// 3 = 2 CPUs
// 1 = 1 CPU
nSet := nCPU
FOR i := 1 to 32 // count processors
IF nCPU // processor present
aadd(aSet, i) // add processor id to list
ENDIF
NEXT
IF len(aSet) > 1 // more then one processor
IF Fexists(cFile)
nHnd := Fopen(cFile, FO_READWRITE)
IF nHnd > 0 // file is open
nLast := Val(Freadstr(nHnd, 2))+ 1 // get last processor
IF nLast > len(aSet) // check against available processors
nLast := 1 // recycle number
ENDIF
Fseek(nHnd, 0, FS_SET) // place pointer at bof
Fwrite(nHnd, StrZero(nLast, 2)) // write to file
Fclose(nHnd) // close file
ENDIF
ELSE // first time round
nHnd := Fcreate(cFile, FC_NORMAL)
IF nHnd > 0 // file is created and open
Fwrite(nHnd, StrZero(nLast, 2)) // write to file
Fclose(nHnd) // close file
ENDIF
ENDIF
FOR i := 1 to 32 // create new bitmask
nSet := (i = aSet[nLast]) // switch on appropriate bit
NEXT
DllCall("xpprt1.dll", DLL_CDECL, "_sysSetCPU", nSet)
ENDIF
RETURN nil
Thanks
Fred
Omni
I am using your example and have for a while. A new client has 16 cpu's`Can that be handled by increasing the vars.
LOCAL nHnd := 0 // file handle
LOCAL nLast := 1 // last CPU used
LOCAL aSet := {} // processor array
LOCAL nSet // default new bitmask
LOCAL i // counter
//DEFAULT cFile := GetEnv('WINDIR') + '\Temp\SetCpu.Smp'
DEFAULT cFile := vdrive+"\oiswin\SetCpu.Smp"
DEFAULT nCPU := 15
// 15 = 4 CPUs
// 7 = 3 CPUs
// 3 = 2 CPUs
// 1 = 1 CPU
nSet := nCPU
FOR i := 1 to 32 // count processors
IF nCPU // processor present
aadd(aSet, i) // add processor id to list
ENDIF
NEXT
IF len(aSet) > 1 // more then one processor
IF Fexists(cFile)
nHnd := Fopen(cFile, FO_READWRITE)
IF nHnd > 0 // file is open
nLast := Val(Freadstr(nHnd, 2))+ 1 // get last processor
IF nLast > len(aSet) // check against available processors
nLast := 1 // recycle number
ENDIF
Fseek(nHnd, 0, FS_SET) // place pointer at bof
Fwrite(nHnd, StrZero(nLast, 2)) // write to file
Fclose(nHnd) // close file
ENDIF
ELSE // first time round
nHnd := Fcreate(cFile, FC_NORMAL)
IF nHnd > 0 // file is created and open
Fwrite(nHnd, StrZero(nLast, 2)) // write to file
Fclose(nHnd) // close file
ENDIF
ENDIF
FOR i := 1 to 32 // create new bitmask
nSet := (i = aSet[nLast]) // switch on appropriate bit
NEXT
DllCall("xpprt1.dll", DLL_CDECL, "_sysSetCPU", nSet)
ENDIF
RETURN nil
Thanks
Fred
Omni