How to refer "kern.hz" in C ?

Sir./Madam,

How to refer "kern.hz" in C
Or how to refer "int hz" defined in subr_param.h in C?

I am writing a PCIe driver on FreeBSD.

Sincerely,
Liu
 
liuwang said:
Or how to refer "int hz" defined in subr_param.h in C?
That variable is not static, so in kernel space you should be able to simply write
Code:
extern int hz;
However, seeing as this variable is not "exported" (for lack of a better word) by a header file, you're probably not supposed to mess with it directly. Aren't there any system calls that do what you want?

Fonz
 
fonz,

Thanks your help.

The system call to get the 'hz' could not be found.

Seeing:
Code:
//'hz' is globally defined in /usr/src/sys/kern/subr_param.c
...
83 int	hz; 
...

//It is refered in /usr/src/sys/sys/kernel.h
...
61 extern int hz;				/* system clock's frequency */
...

//And is refered in /usr/src/sys/netinet/cc/cc_cubic.h
...
74 extern int hz;
...

//But when it is refered in mycode.h
...
extern int hz;
...
//and in mycode.c
...
m = hz / 1000;
...
//It reports error:
...
mycode.c:54:5: error: "hz" is not defined
...

Sincerely,
Liu
 
Back
Top