Delphi-PRAXiS
Seite 7 von 7   « Erste     567   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   core2duotemp.c to core2duotemp.pas (https://www.delphipraxis.net/97137-core2duotemp-c-core2duotemp-pas.html)

devidespe 30. Mai 2008 15:31

Re: core2duotemp.c to core2duotemp.pas
 
Actually like this:

Delphi-Quellcode:
FUNCTION SetProcessorNr(Nr : Byte) : Boolean; {0 until 31}
VAR Process : THandle;
BEGIN
  Process:=GetCurrentProcess;
  Result:=SetProcessAffinityMask(Process, (1 SHL Nr));
END;
This function must run within a FOR-TO-DO loop to set the processors. The number of processors (which is part of the FOR-TO-DO loop) can be detected by using the GetSystemInfo function (here), where the SYSTEM_INFO structure (here again) contains the value dwNumberOfProcessors as DWord.

Hope that helps.

Razor 30. Mai 2008 15:48

Re: core2duotemp.c to core2duotemp.pas
 
Well this wont work


Delphi-Quellcode:
procedure TMainFrm.JvThreadTimer1Timer(Sender: TObject);
var
msr:tmsr;
omcdrv:tmsrio;
x:dword;
s:string;
o:integer;
begin
SetThreadAffinityMask(jvthreadtimer1.Thread.Handle,$0008);//for the 4th core
omcdrv.ReadMSR($19C,msr);

x := msr.LowPart;
x:=x shr 16 and $0000ff     ;
s:=Format('%8.8x', [x]);
o:=100-HexToInt(S);
rzlabel8.caption:=inttostr(o)+' °C';
end;

Razor 30. Mai 2008 16:03

Re: core2duotemp.c to core2duotemp.pas
 
Ok ok i wrote a function however it dosent do its job very well...

Delphi-Quellcode:
Function IntelCore(ThreadAffinity:Cardinal;Mask:dword):string;
var
msr:tmsr;
omcdrv:tmsrio;
x:dword;
s:string;
o:integer;
begin
SetThreadAffinityMask(ThreadAffinity,mask);
omcdrv.ReadMSR($19C,msr);

x := msr.LowPart;
x:=x shr 16 and $0000ff     ;
s:=Format('%8.8x', [x]);
o:=100-HexToInt(S);
result:=inttostr(o)+' °C';
end;

Am i confused couse i cant figure the mask for the thread....please! :wall:

Muetze1 30. Mai 2008 21:49

Re: core2duotemp.c to core2duotemp.pas
 
Zitat:

Zitat von Razor
Delphi-Quellcode:
...
s:=Format('%8.8x', [x]);
o:=100-HexToInt(S);
...

Oh my god. So I see, you have not learned anything. All I see in this small part, that you have not understand something from our ICQ contact. It is really sad to this...

Zitat:

Zitat von Razor
Am i confused couse i cant figure the mask for the thread....please! :wall:

You use a external ring-0 driver, so this setting in your application/process/thread will not change anything. Your driver offers the option to pass the affinity mask within the calls. You have to use this parameter. Any call to SetProcessAffinityMask() or to SetThreadAffinityMask() will only be honoured by code in your application/thread. As I know, you do nothing inside your app, so it is useless.

Learn the things you do and stop copying!

devidespe 31. Mai 2008 10:13

Re: core2duotemp.c to core2duotemp.pas
 
Zitat:

Zitat von Muetze1
You use a external ring-0 driver, so this setting in your application/process/thread will not change anything. Your driver offers the option to pass the affinity mask within the calls. You have to use this parameter. Any call to SetProcessAffinityMask() or to SetThreadAffinityMask() will only be honoured by code in your application/thread. As I know, you do nothing inside your app, so it is useless.

Thats right, but for that you have to use the RdmsrEx function instead of Rdmsr. Only the RdmsrEx function contains the AffinityMask as DWord Pointer.

I hope he can solve this problem... At least there is a C and C++ sample, which demonstrates how to use this affinity setting.

Razor 31. Mai 2008 10:51

Re: core2duotemp.c to core2duotemp.pas
 
Liste der Anhänge anzeigen (Anzahl: 1)
Guys i already did that with the RdMsrEx it works fine it was ment for other driver but ok.


Now another problemo Cpu detection and cpuid...i guess thats hard as hell. :gruebel:


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:10 Uhr.
Seite 7 von 7   « Erste     567   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz