public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: nanosleep
@ 2002-04-10  5:57 mark manning
  2002-04-10  6:01 ` nanosleep Robert Love
  0 siblings, 1 reply; 10+ messages in thread
From: mark manning @ 2002-04-10  5:57 UTC (permalink / raw)
  To: linux-kernel

hrm - im confiused now - how can you do a n NANO second delay when the resolution is 10 mili seconds ?

forgive my ignorance and my persistant "stupid" questions :)

----- Original Message -----
From: "H. Peter Anvin" <hpa@zytor.com>
Date: 	9 Apr 2002 22:47:42 -0700
To: linux-kernel@vger.kernel.org
Subject: Re: nanosleep


> Followup to:  <20020410044243.2916.qmail@fastermail.com>
> By author:    "mark manning" <mark.manning@fastermail.com>
> In newsgroup: linux.dev.kernel
> >
> > thanx - how much of a difference should i expect - i know the
> > syscall is asking for at least the required ammount but that the
> > task switcher might not give me control back for a while after the
> > requested delay but i was expecting to be a little closer to what i
> > had asked for - this isnt critical of corse but i would like to know
> > what to expect.
> > 
> 
> Read the man page:
> 
> BUGS
>        The current implementation of nanosleep is  based  on  the
>        normal  kernel  timer mechanism, which has a resolution of
>        1/HZ s (i.e, 10 ms on Linux/i386 and 1 ms on Linux/Alpha).
>        Therefore, nanosleep pauses always for at least the speci
>        fied time, however it can take up to  10  ms  longer  than
>        specified  until  the  process becomes runnable again. For
>        the same reason, the value returned in case of a delivered
>        signal  in *rem is usually rounded to the next larger mul
>        tiple of 1/HZ s.
> 
>        As some applications  require  much  more  precise  pauses
>        (e.g.,  in  order to control some time-critical hardware),
>        nanosleep is also capable of short high-precision  pauses.
>        If  the process is scheduled under a real-time policy like
>        SCHED_FIFO or SCHED_RR, then pauses of up to 2 ms will  be
>        performed as busy waits with microsecond precision.
> 
> 	-hpa
> -- 
> <hpa@transmeta.com> at work, <hpa@zytor.com> in private!
> "Unix gives you enough rope to shoot yourself in the foot."
> http://www.zytor.com/~hpa/puzzle.txt	<amsp@zytor.com>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 

_______________________________________________
Get your free email from http://www.fastermail.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: nanosleep
@ 2002-04-10  4:42 mark manning
  2002-04-10  5:47 ` nanosleep H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: mark manning @ 2002-04-10  4:42 UTC (permalink / raw)
  To: linux-kernel


thanx - how much of a difference should i expect - i know the syscall is asking for at least the required ammount but that the task switcher might not give me control back for a while after the requested delay but i was expecting to be a little closer to what i had asked for - this isnt critical of corse but i would like to know what to expect.


----- Original Message -----
From: "H. Peter Anvin" <hpa@zytor.com>
Date: Tue, 09 Apr 2002 21:17:03 -0700
To: mark manning <mark.manning@fastermail.com>
Subject: Re: nanosleep


> mark manning wrote:
> > doh - i think something is still wrong, i ask for 1000 ms and i get a second but if i do a 500 itteration loop asking for 1 ms i get 5 seconds.  i am also starting to distrust my elapsed time display which is using the gettimeofday syscall
> > 
> 
> It doesn't work that way.  Each call to nanosleep() gives you a 
> *MINIMUM* time to delay.  The kernel may decide to schedule you away and 
> pick your process up when it suits it.
> 
> 	-hpa
> 
> 
> 

-- 

_______________________________________________
Get your free email from http://www.fastermail.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: nanosleep
@ 2002-04-10  4:41 mark manning
  2002-04-10  5:57 ` nanosleep Robert Love
  0 siblings, 1 reply; 10+ messages in thread
From: mark manning @ 2002-04-10  4:41 UTC (permalink / raw)
  To: linux-kernel


thanx - how much of a difference should i expect - i know the syscall is asking for at least the required ammount but that the task switcher might not give me control back for a while after the requested delay but i was expecting to be a little closer to what i had asked for - this isnt critical of corse but i would like to know what to expect.


----- Original Message -----
From: "H. Peter Anvin" <hpa@zytor.com>
Date: Tue, 09 Apr 2002 21:17:03 -0700
To: mark manning <mark.manning@fastermail.com>
Subject: Re: nanosleep


> mark manning wrote:
> > doh - i think something is still wrong, i ask for 1000 ms and i get a second but if i do a 500 itteration loop asking for 1 ms i get 5 seconds.  i am also starting to distrust my elapsed time display which is using the gettimeofday syscall
> > 
> 
> It doesn't work that way.  Each call to nanosleep() gives you a 
> *MINIMUM* time to delay.  The kernel may decide to schedule you away and 
> pick your process up when it suits it.
> 
> 	-hpa
> 
> 
> 

-- 

_______________________________________________
Get your free email from http://www.fastermail.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: nanosleep
@ 2002-04-10  3:22 mark manning
  0 siblings, 0 replies; 10+ messages in thread
From: mark manning @ 2002-04-10  3:22 UTC (permalink / raw)
  To: hahn; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

hi - yes i read the man pages, im already using nanosleep for doing 1 second delays and i chose nanosleep because a signal can interrupt the delay which might be useful (and might not :)

----- Original Message -----
From: Mark Hahn <hahn@physics.mcmaster.ca>
Date: Tue, 9 Apr 2002 20:32:03 -0400 (EDT)
To: mark manning <mark.manning@fastermail.com>
Subject: Re: nanosleep


> > could someone show me how to do a delay of N miliseconds using nanosleep ?
> > (given n delay n mili seconds etc) - i cant seem to get my code to work
> > doh! 
> 
> did you read the fine man page, esp the section on resolution
> and busy-waits?  also, using select for its timeout is probably
> more portable.
> 
> 

-- 

_______________________________________________
Get your free email from http://www.fastermail.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 10+ messages in thread
* nanosleep
@ 2002-04-09 23:24 mark manning
  0 siblings, 0 replies; 10+ messages in thread
From: mark manning @ 2002-04-09 23:24 UTC (permalink / raw)
  To: linux-kernel


could someone show me how to do a delay of N miliseconds using nanosleep ? (given n delay n mili seconds etc) - i cant seem to get my code to work doh!
-- 

_______________________________________________
Get your free email from http://www.fastermail.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-04-14 20:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-10  5:57 nanosleep mark manning
2002-04-10  6:01 ` nanosleep Robert Love
2002-04-13 21:53   ` nanosleep andrew may
2002-04-14 20:37     ` nanosleep H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2002-04-10  4:42 nanosleep mark manning
2002-04-10  5:47 ` nanosleep H. Peter Anvin
2002-04-10  4:41 nanosleep mark manning
2002-04-10  5:57 ` nanosleep Robert Love
2002-04-10  3:22 nanosleep mark manning
2002-04-09 23:24 nanosleep mark manning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox