Hi, I had originally posted this question yesterday, but due to my lack of understanding of how posting on this board works, the question posting got garbled up. Hence reposting with my understanding of the problem so far. Being a novice at perl, I have been tasked with modifying a perl script that binds specific processes to a specific processor. It does this either by executing a script that returns the next available processor or finding similar processes and then binding to the processor used by those processes. The change I am implementing is the "binding to processor number returned by the script" part. I am trying to accomplish this using the following piece of code:
$processor = `/aa/bin/get_bind_cpus.ksh`
However owing to the fact that strict refs is enforced throughout the perl script, I get the error:
Error Converting from string to SCALAR in line 325 . that line runs as below:
my $mgr = shift;
my $processor = shift;
my $proc_id = locate_process_id( $mgr );
foreach ( keys %{$proc_id} )
{
next unless defined $$proc_id{$_};
system("$os_command_table{$^O}{pbind} -b $$processor $
+$proc_id{$_} >/dev/null 2>&1")
if defined $$processor;
}
}
}
This processor variable is also populated at anbother location (where the script tries to find similar processes using the same processor and bind to that) as illustrated by the code sample below:
sub get_cpu_used_by_other_proc
{
my $other_mgr = shift;
my $proc_id = locate_process_id( $other_mgr );
my $processor = undef;
my $pid = undef;
my @cmd_output = `$os_command_table{$^O}{pbind} -q 2>/dev/null
+`;
die "ERROR:failed to retrieve the bound processors\n" unless (
+ $? == 0 );
##### increase the weight of processors based on used or not #
+####
foreach ( keys %{$proc_id} )
{
$pid = $$proc_id{$_};
next unless defined $pid;
foreach ( @cmd_output )
{
$processor = $1, return \$processor if /proces
+s\s+id\s+${pid}\s*:\s*(\d+)$/;
}
}
}
My simple question is how should the line of code I am trying to introduce:
$processor = `/aa/bin/get_bind_cpus.ksh`
be modified so that it populates the processor scalar correctly so that it dosent bomb onthe call to pbind:
system("$os_command_table{$^O}{pbind} -b $$processor $
$proc_id{$_} >/dev/null 2>&1")
Help is appreciated
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.