Skip to contentSkip to conversation

Strange results with changing HZ

DISCUSSION Wojciech Kromer 2 participants 3 messages Nov 21, 2005 – Dec 9, 2005

lore
Share & tools
lore
#0 lore 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;
}

#1 lore raw
Quoted 7 lines · Wojciech Kromer

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.

Just an uneducated guess, but are you sure uclibc doesn't depend on HZ at all? Some things might be just straight syscalls, others might be implemented in userspace (inside uclibc)... for example alarm(1) programming an alarm on jiffies+1/HZ, and HZ being compiled in from kernel headers ?
I may just be talking rubbish though.

Greetings,

Signature · 1 line
David Jander
#2 lore raw
Quoted 9 lines · Użytkownik David Jander
Quoted 6 lines · Wojciech Kromer

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

Quoted 9 lines
Quoted 3 lines

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

Just an uneducated guess, but are you sure uclibc doesn't depend on HZ at all?
Some things might be just straight syscalls, others might be implemented in userspace (inside uclibc)... for example alarm(1) programming an alarm on jiffies+1/HZ, and HZ being compiled in from kernel headers ? I may just be talking rubbish though.

Hmm, after recompiling whole uclibc stuff it seem to work same.
There should be kernel problem. Sleep & select works fine, but alarm works 10 times faster.

Anyone tries to change HZ to 1000?