Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HZ variable not defined

I'm trying to compile someone's code right now and the person is using a variable HZ (which I think stands for Hertz for the hertz of the cpu) but the compiler is complaining that the variable is not defined. My guess is that the person didn't include the correct header file.

So does anyone know which header file, HZ is defined in?

Thanks

Edit: Compilation works on Debian g++ version 4.3.2
The setup I'm using - OSX Leopard 10.5.8, g++ version 4.0.1 is where it fails.

like image 847
Opt Avatar asked Mar 17 '26 23:03

Opt


2 Answers

Paul's answer is correct, but I'll expand a little.

Linux has a compile-time option which determines the frequency of the kernel's timer. At approximately the frequency that HZ is defined to, the kernel scheduler will interrupt processes and begin its scheduling work. (A related feature is the DynTicks option, which elides the HZ value, and changes the interrupt frequency based on the workload.) The most common setting is 100. Highly responsive systems might use 1000. Recent kernel versions use a default of 250. Systems with heavy computational workloads might use a smaller value (to minimize the effect of the scheduler).

Thus it is a very Linux-specific value, and you'll only find it defined in /usr/include/asm/param.h

Since 100 is a common value, you might be safe in simply adding -DHZ=100 to your CXXFLAGS variable. This will by no means mean that the program will actually work on OS X, only that it might compile.

like image 62
greyfade Avatar answered Mar 19 '26 12:03

greyfade


On my Linux box, it's defined in /usr/include/asm/param.h:#define HZ 100

I can't find a definition anywhere on my Mac OS X box.

like image 20
Paul Tomblin Avatar answered Mar 19 '26 11:03

Paul Tomblin