Re: Sockets and Sleep Question

2002-10-04 Thread Michael Fowler

On Thu, Oct 03, 2002 at 05:12:38PM -0700, Jessee Parker wrote:
 I will definitely take a look at this. How do you determine what your
 current nice status is?

nice, with no arguments, will give you your current nice level.  ps and top
will diplay the nice level (or sometimes priority) of processes.  Also,
BSD::Resource, found on CPAN, has a method for retrieving a process's
priority.  I'm fairly certain there are more ways of getting the information.

 
  How did you verify the condition was never reached?  If you determined it
  independently of the program printing to its log file then I'd have to see
  the code to be able to tell you what's going on.
 
 What I did was had top running and watched the load average.

Ok, the test was seperate.  Have you tried running strace on the program to
see where it's sleeping?  Are you certain it's sleeping, or is it possible
it's blocking on a read or write?


 The code I am using to check the load average is this:
 
 $highload = .8;
 while (($currload = Load)  $highload)
 {
 print LOG Sleeping\n;
 sleep 5;
 }
 
 sub Load {
 # Test system load and wait if it's too high
 @uptime = split(/,/, `uptime`);
 $fraction = $uptime[3];
 $load = (split /:/, $fraction)[1];
 return $load;
 }

This code doesn't work for me, though it may be because of a difference in
uptime output.  Have you verified Load() returns the value you expect?

Also, Load has slightly different meaning from Load(), due to the .  It
doesn't look like it will effect you here, but you should check perldoc
perlsub for the difference between them.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Sockets and Sleep Question

2002-10-03 Thread Michael Fowler

On Thu, Oct 03, 2002 at 10:10:34AM -0700, Jessee Parker wrote:
 At the top of the loop, I check the system uptime to get the load average
 so I can have the program sleep for 5 seconds to let things stabilize a
 bit.

I suspect an easier way of doing this would be to nice yourself down really
low; see man nice.  There may be a Perl module available on CPAN for doing
this, as well.


 When this happens, the message Sleeping is printed out to a log file.
 However, I noticed that the program ended up sleeping without printing the
 message.

It sounds to me like you might be having a buffering issue; while the
process did print before going to sleep, the output was never flushed to the
file.  See http://perl.plover.com/FAQs/Buffering.html. 


 The condition I set for load average was never reached so there was no
 reason for it to sleep. I ran a netstat -an and there were alot of tcp
 connections to port 25 in the TIME_WAIT mode.

How did you verify the condition was never reached?  If you determined it
independently of the program printing to its log file then I'd have to see
the code to be able to tell you what's going on.


 What I'm trying to figure out is if the OS or Perl itself puts a limit on
 processes when it has a large number of connections in that mode forcing
 it to sleep. I am running this on Redhat Linux version 7.3.

Unix operating systems do have methods of limiting the number of open file
descriptors for a given process, as well as system-wide.  However, the
typical response when you reach this limit is to kill the offending process,
not to put it to sleep.  This is how Linux process limits operate.

Perl doesn't impose limits on resource usage.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Sockets and Sleep Question

2002-10-03 Thread Jessee Parker

 On Thu, Oct 03, 2002 at 10:10:34AM -0700, Jessee Parker wrote:
  At the top of the loop, I check the system uptime to get the load
average
  so I can have the program sleep for 5 seconds to let things stabilize a
  bit.

 I suspect an easier way of doing this would be to nice yourself down
really
 low; see man nice.  There may be a Perl module available on CPAN for doing
 this, as well.


I will definitely take a look at this. How do you determine what your
current nice status is?


  When this happens, the message Sleeping is printed out to a log file.
  However, I noticed that the program ended up sleeping without printing
the
  message.

 It sounds to me like you might be having a buffering issue; while the
 process did print before going to sleep, the output was never flushed to
the
 file.  See http://perl.plover.com/FAQs/Buffering.html.


  The condition I set for load average was never reached so there was no
  reason for it to sleep. I ran a netstat -an and there were alot of tcp
  connections to port 25 in the TIME_WAIT mode.

 How did you verify the condition was never reached?  If you determined it
 independently of the program printing to its log file then I'd have to see
 the code to be able to tell you what's going on.


What I did was had top running and watched the load average. The code I am
using to check the load average is this:

$highload = .8;
while (($currload = Load)  $highload)
{
print LOG Sleeping\n;
sleep 5;
}

sub Load {
# Test system load and wait if it's too high
@uptime = split(/,/, `uptime`);
$fraction = $uptime[3];
$load = (split /:/, $fraction)[1];
return $load;
}

The buffering information is great, but I will have to wait until the
next run to see if that is indeed why Sleeping isn't being printed out.
When I do local tests, I can print Sleeping to the screen with no problem.
Even when I take out the LOG in the above, Sleeping does not get printed
out with an actual run of data (an actual run being subscriber e-mail
addresses versus e-mail accounts I have set up on various sites for
testing).




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




sleep question

2002-09-12 Thread Chad Kellerman

Greetings,
 I have a script that forks 5 children.  I print to screen when each
child gets forked.  Under certain conditions in the script a child
should sleep.  This conditions occurs at different times for each child.

 I think I am noticing that when the sleep is called in a child,
every child and the parent sleep as well.

  Am I correct in this assumption?  The OS that the script is running on
is Solaris.

Thanks,
CHad

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: sleep question

2002-09-12 Thread Bob Showalter

 -Original Message-
 From: Chad Kellerman [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, September 12, 2002 12:37 PM
 To: [EMAIL PROTECTED]
 Subject: sleep question
 
 
 Greetings,
  I have a script that forks 5 children.  I print to 
 screen when each
 child gets forked.  Under certain conditions in the script a child
 should sleep.  This conditions occurs at different times for 
 each child.
 
  I think I am noticing that when the sleep is called in a child,
 every child and the parent sleep as well.
 
   Am I correct in this assumption?

No. After the fork, parent and child lead separate lives. Something else is
going on.

 The OS that the script is 
 running on
 is Solaris.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]