The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sleep working meetbhattu UNIX for Advanced & Expert Users 2 10-29-2007 02:05 PM
Sleep Command Glove Shell Programming and Scripting 1 10-03-2007 02:02 AM
Sleep() not working enuenu High Level Programming 2 06-01-2007 10:01 PM
Sleep under one second Scoogie Shell Programming and Scripting 5 08-14-2002 05:10 AM
sleep Anna UNIX for Dummies Questions & Answers 5 07-10-2001 08:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 08-24-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
Quote:
Originally Posted by jim mcnamara
IT's not hard to measure the elapsed time:
Put Perderabo's code in a script, call it usleep.sh
Code:
time usleep.sh
will give you something like this:
Code:
kcsdev:/home/jmcnama> time usleep.sh

real    0m0.18s
user    0m0.03s
sys     0m0.05s
real is the elapsed time.

that's right, but... you have to consider the time it takes to load/initialize perl itself and how does that time relate to the actual 'sleep' time. Take a look here:
Code:
time perl -e 'select(undef,undef,undef,.001)'

real    0m0.030s
user    0m0.010s
sys     0m0.010s
The only real implementation would be a shell builtin, which ksh doesn't have. So perl is your best approximation.
Reply With Quote
Forum Sponsor
  #9  
Old 08-24-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,269
You're saying that the usleep doesn't "usleep" for just .1 seconds, right?

It does not matter in a multiuser, multiprocessing system. When a process "sleeps"
for any time slice, the time slice is the guaranteed minimum, not the max possible or even what normally will happen. The actual wait is dictated by the quantum (time slice), the base priority of the "waking up" process relative to anybody else wating for the cpu, and the length of the queue of processes waiting for the CPU.

So, if there were three same-priority processes ahead of you, the time slice is 100ms
(.1 second) and you wake up from sleep, the total sleep time could be as much as
the time you spent alseep plus the wait for three other processes to complete their quanta - in this case 100ms of sleep + (3 * 100ms) quantum slices = 400ms.
Reply With Quote
  #10  
Old 08-25-2005
Registered User
 

Join Date: Aug 2005
Location: Sweden
Posts: 5
Thanks vgersh99 and jim mcnamara for your great help. This is exactly what
i want and with the explanations you gave me i know how to use it.

Thanks a lot
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0