• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 762
  • Last Modified:

Perl multiprocessing on multi processors

Hi everyone

Just thought if anyone did this

create a perl application to assign multiple perl process and control those assignments to a multiple processors that reside on WinNT machine. if you have a sample code it would certanly help.

so this is basicaly control of the multiple process and to which processor the process gets assigned to.

highly appreciated

L.  
0
ledeni
Asked:
ledeni
  • 4
  • 3
1 Solution
 
kanduraCommented:
I would suggest you leave process scheduling to the OS scheduler. Even if the OS is only Windows NT, it most likely does a better job than just assigning each process to a different CPU.
0
 
ledeniAuthor Commented:
thanks kandura for your response ...

unfortunately that does not seem to be a good thing at least for me since WintNT at least in my case, seem to shaf everything to 1st procesor untill full and then start looking at the other one ..

Through perl I am creating a process that call another VERY high volume application and at least when I create a first process the 80 % of procesor is taken .. when I create a 2nd process the OS tries to put it into another 20% of available space within first procesor...

for that reason I need an ability to control that.

On the other hand I am using Win32::Process library to create multiple process .. do you know if there is anything better for that ??

Thanks a bunch

L.
0
 
kanduraCommented:
sounds like WinNT does *not* do such a great job...

Win32::Process sounds like the way to go. You could use the SetProcessAffinityMask method on the process.

From the documentation:

    $ProcessObj->GetProcessAffinityMask($processAffinityMask, $systemAffinityMask)
   
        Get the process affinity mask. This is a bitvector in which each bit represents the processors that a process is allowed to run on.

    $ProcessObj->SetProcessAffinityMask($processAffinityMask)
   
        Set the process affinity mask. Only available on Windows NT.

Not sure if they really mean a vec() thing, or just something like 0x01 & 0x02.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ledeniAuthor Commented:
its Windoz what else to expect :)

the hex val seem more appropriate .. do you know if I can pick up the num of process through perl so that I make it dynaminc instead of a static assignment of processors ???

thanks a bunch
0
 
kanduraCommented:
I have no idea how to get the number of CPU's on Windows. Win32::Perflib might help, or Win32::API. I'm sure it's a call in kernel.dll somewhere :-)
0
 
kanduraCommented:
Yup. Here you go :-)


    use Win32::API;
   
    typedef Win32::API::Struct SYSTEM_INFO => qw{
        int dwOemId;
        int dwPageSize;
        int lpMinimumApplicationAddress;
        int lpMaximumApplicationAddress;
        int dwActiveProcessorMask;
        int dwNumberOfProcessors;
        int dwProcessorType;
        int dwAllocationGranularity;
        int dwProcessorLevel;
        int dwProcessorRevision;
      };
     
    Win32::API->Import('kernel32', 'BOOL GetSystemInfo(LPSYSTEM_INFO si)');
   
    my $si = Win32::API::Struct->new('SYSTEM_INFO');
   
    GetSystemInfo($si);
   
    print "#cpus: ", $si->{dwNumberOfProcessors}, $/;
   
   
0
 
ledeniAuthor Commented:
ata boy kendura .. thanks a bunch for your help
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now