public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Piel <Eric.Piel@lifl.fr>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: Dag Nygren <dag@newtech.fi>, linux-kernel@vger.kernel.org
Subject: Re: nanosleep with small value
Date: Thu, 17 Nov 2005 18:32:31 +0100	[thread overview]
Message-ID: <437CBEAF.5000101@lifl.fr> (raw)
In-Reply-To: <Pine.LNX.4.61.0511171146310.9422@chaos.analogic.com>

11/17/2005 05:55 PM, linux-os (Dick Johnson) wrote/a écrit:
> On Thu, 17 Nov 2005, Dag Nygren wrote:
:
>>
>>real    0m8.000s
>>user    0m0.000s
>>sys     0m0.000s
> 
> 
> On an unprivilged account, I get this with
> version 2.6.13.4
> 
> Script started on Thu 17 Nov 2005 11:44:47 AM EST
> LINUX> time ./xxx
> sched_setscheduler returned: -1
> Operation not permitted
> 
> real	0m2.000s
> user	0m0.000s
> sys	0m0.001s
> LINUX> uname -r
> 2.6.13.4
> LINUX> exit
> Script done on Thu 17 Nov 2005 11:45:07 AM EST
> 
>>From the root account where the scheduler could be set:
> 
> Script started on Thu 17 Nov 2005 11:45:29 AM EST
> [root@chaos root]# time /tmp/xxx
> 
> real	0m2.001s
> user	0m0.000s
> sys	0m0.001s
> [root@chaos root]# exit
> 
> Script done on Thu 17 Nov 2005 11:45:53 AM EST
> 
> ... essentially the same thing. And 2 seconds, not 8.
> 
> The HZ value for my kernel is 1000. It you are at 100 HZ,
> that might explain it.
No, it means he is at 250 HZ.


> 
> Note that nanosleep() doesn't claim to be able to sleep
> less than the resolution of some kernel timer. It just takes
> parameters in seconds and nanoseconds.
> 
In general small nanosleep() returns between 1/HZ and 2/HZ. In this 
code, the sleep is (indirectly) synchronised on a tick so it's always 
2/HZ, the worse!

1000 small nanosleeps take therefore 1000 * 2/HZ s = 8s :-)

Eric

  reply	other threads:[~2005-11-17 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 16:30 nanosleep with small value Dag Nygren
2005-11-17 16:55 ` linux-os (Dick Johnson)
2005-11-17 17:32   ` Eric Piel [this message]
2005-11-17 17:12 ` Nish Aravamudan
2005-11-17 18:47   ` Dag Nygren
     [not found] <29495f1d0511171051q6088099drfe094817a01668e4@mail.gmail.com>
2005-11-17 19:11 ` Dag Nygren
2005-11-17 19:15   ` Randy.Dunlap
2005-11-17 19:17   ` Nish Aravamudan
2005-11-17 19:47   ` Frank Sorenson
2005-11-21  7:12     ` Dag Nygren
  -- strict thread matches above, loose matches on Subject: below --
2005-11-17 20:25 Dag Nygren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=437CBEAF.5000101@lifl.fr \
    --to=eric.piel@lifl.fr \
    --cc=dag@newtech.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox