Hello,

I tried each of the suggestions mentioned and the same error occurs. 
Unfortunately, once I click ok on the error message box, the application 
terminates without displaying any additional information.

I also tried to accomplish this task directly via the Windows API and also was 
unsucessful. Interestingly, calling the API routines from VB6 also did not 
work, although it did work from VB.NET. Therefor, until I can get this logic to 
work in Perl, I have a workaround using .NET. I created a VB.NET application 
which accepts a process id as a runtime parameter and will change the process 
affinity mask for that id. I can use the system command to execute the VB.NET 
application from the Perl process.

Thanks,
Ray


-----Original Message-----
From: Sisyphus [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 21, 2006 2:06 AM
To: Ray Albert; [email protected]
Subject: Re: Windows2000 Process Affinity



----- Original Message ----- 
From: "Ray Albert" <[EMAIL PROTECTED]>
To: "Sisyphus" <[EMAIL PROTECTED]>;
<[email protected]>
Sent: Saturday, January 21, 2006 2:55 AM
Subject: RE: Windows2000 Process Affinity


> Hello,
>
> Following is the code I am running to retrieve current processor affinity,
and reduce the number of cpus by one. The call to the
GetProcessAffinityMask() method is successful. I get a memory reference
error when calling the SetProcessAffinityMask() method.
>
>
> Win32::Process::Open($hprocess,$$,1); #open process for current processid
>
>
$hprocess->GetProcessAffinityMask($processaffinitymask,$systemaffinitymask);
>
> if (($processaffinitymask > 1) && ($processaffinitymask % 2 == 1)) {
>
> #remove cpu0 from affinity mask
> $processaffinitymask--;
>
> $hprocess->SetProcessAffinityMask($processaffinitymask);
> }
>

Hmm .... probably can't help much - not aided by the fact that I don't have
access to a multi-cpu machine :-)

Do you get any diagnostic printed to the console *after* you acknowledge the
memory reference error ?

Did you try:
if(!$hprocess->SetProcessAffinityMask($processaffinitymask)) {print $^E};
(Faik, the segfault will prevent you from seeing $^E .... I'm not sure.)

Does it work ok if you comment out the line '$processaffinitymask--' ?

Presumably $processaffinitymask has an initial value of 3. What happens if
you set it to 1 ?

*Should* one be able to remove a CPU from the current process ? (I mean "Is
that allowed ?")

If you create a process with Win32::Process::Create(), can you then set the
mask to remove a cpu ? ... or do you get essentially  the same error ?

Cheers,
Rob



_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to