public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: setitimer 1 usec fails
@ 2003-05-27 17:19 Richard C Bilson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard C Bilson @ 2003-05-27 17:19 UTC (permalink / raw)
  To: Eric.Piel, george; +Cc: akpm, davidm, linux-kernel

> From Eric.Piel@Bull.Net  Tue May 27 05:05:53 2003
> 
> With the patch atatched the bug seems to go away, for the 030521 release
> of IA64 patch (and probably the previous release also). Could you
> confirm, Richard? I think it's kind of architecture specific because
> this bug shouldn't happen with HZ=1000 (i386) ;-)

Yes -- it fixes the program I posted, as well as my original program.
Thanks very much, Eric!

- Richard

^ permalink raw reply	[flat|nested] 6+ messages in thread
* setitimer 1 usec fails
@ 2003-05-26 21:09 Richard C Bilson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard C Bilson @ 2003-05-26 21:09 UTC (permalink / raw)
  To: linux-kernel

In trying the latest development kernel, I've noticed that calling
setitimer with a 1 usec delay (the shortest possible delay) results in
the timer never going off.  2 usec is ok but 1 is not, so I suspect
that somehow things are being rounded off incorrectly.  The attached
program demonstrates the problem on 2.5.69, but runs correctly on a
2.4.20 kernel.

I have only had the opportunity to try this on a single architecture
(ia64), so if anyone can convince me that it's a platform-specific
problem I'll be happy to take my gripe to the ia64 list.  I've tried to
figure out how the usecs are converted to jiffies, but the code is
sufficiently convoluted that I thought I'd throw it out in the hope of
finding someone who understands the situation a little better.

- Richard

// When run, this program should print "handled alarm" from within the
// signal handler, and "out of sigsuspend" right after.  It works on
// 2.4.20 or if MY_TIMER_USEC is >= 2, but not on 2.5.69 with
// MY_TIMER_USEC = 1.

#define MY_TIMER_USEC 1

#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>

void
alarm_handler( int x )
{
  printf( "handled alarm\n" );
  return;
}

int
main()
{
  struct itimerval it = { { 0, 0 }, { 0, MY_TIMER_USEC } };
  sigset_t mask;
  struct sigaction act;

  act.sa_handler = alarm_handler;
  act.sa_flags = 0;
  sigemptyset( &act.sa_mask );
  if( sigaction(SIGALRM, &act, 0) ) {
    perror( "sigaction" );
    exit( 1 );
  }
  
  if( setitimer(ITIMER_REAL, &it, 0) ) {
    perror( "setitimer" );
    exit( 1 );
  }
  
  sigemptyset( &mask );
  sigsuspend( &mask );
  
  printf( "out of sigsuspend\n" );
  return 0;
}

-- 
Richard C. Bilson, Research Assistant   | School of Computer Science
rcbilson@plg.uwaterloo.ca               | University of Waterloo
http://plg.uwaterloo.ca/~rcbilson       | 200 University Avenue West
Office: DC 3548F Ph: (519)888-4567x4822 | Waterloo, Ontario, CANADA N2L 3G1

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

end of thread, other threads:[~2003-05-27 19:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20030526142555.67a79694.akpm@digeo.com>
2003-05-26 22:00 ` setitimer 1 usec fails george anzinger
2003-05-27  9:05   ` Eric Piel
2003-05-27 18:27   ` David Mosberger
2003-05-27 20:01     ` george anzinger
2003-05-27 17:19 Richard C Bilson
  -- strict thread matches above, loose matches on Subject: below --
2003-05-26 21:09 Richard C Bilson

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