All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wojciech Kromer <wojciech.kromer@dgt.com.pl>
To: linuxppc-embedded@ozlabs.org
Subject: Strange results with changing HZ
Date: Mon, 21 Nov 2005 08:44:15 +0100	[thread overview]
Message-ID: <43817ACF.1030903@dgt.com.pl> (raw)

My system is:
 - 2.4.25 kernel from denx.de
 - uclibc (gcc 3.4.2) + busybox
 - changed HZ to 1000
 - rebuild kernel only

AFAIR there souldn't be any need to recompile user apps.

I have strange results.
Sleep and timeout selects works fine, but alarm functions seems to be 
too fast.
For example included program or ping waits too short.



it is OK:

# time alarm_test
alarm fired after 0.099166s
real    0m 0.11s
user    0m 0.00s
sys     0m 0.00s
#
# time sleep 1
real    0m 1.01s
user    0m 0.00s
sys     0m 0.00s
# time sleep 10
real    0m 10.01s
user    0m 0.00s
sys     0m 0.00s


but:

# alarm_test
alarm fired after 0.099709s
# alarm_test
alarm fired after 0.099710s


------------------------------------ alarm_test.c :

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

static void sighand(int sig)
{
}

int main()
{
 struct timeval tv1, tv2;
 sigset_t set;

 sigfillset(&set);
 sigdelset(&set, SIGALRM);
 sigdelset(&set, SIGINT);

 signal(SIGALRM, sighand);
 gettimeofday(&tv1, NULL);

 alarm(1);
 sigsuspend(&set);
 gettimeofday(&tv2, NULL);

 tv1.tv_sec = tv2.tv_sec - tv1.tv_sec - (tv2.tv_usec < tv1.tv_usec);
 tv1.tv_usec = tv2.tv_usec - tv1.tv_usec + (tv2.tv_usec < tv1.tv_usec) * 
1000000;

 printf("alarm fired after %ld.%06lds\n",
 tv1.tv_sec, tv1.tv_usec);

 return 0;
}

             reply	other threads:[~2005-11-21  7:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-21  7:44 Wojciech Kromer [this message]
2005-11-21 11:43 ` Strange results with changing HZ David Jander
2005-12-09 10:33   ` Wojciech Kromer

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=43817ACF.1030903@dgt.com.pl \
    --to=wojciech.kromer@dgt.com.pl \
    --cc=linuxppc-embedded@ozlabs.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.