hello everyone I'm currently reading Understanding the Linux Kernel, I found there:

Besides the fields included in each process descriptor, additional information is needed to describe what each CPU is doing. To that end, the scheduler can rely on the aligned_data array of NR_CPUS structures of type schedule_data.

my question is, where can I find the definition(I mean which directory and file) of NR_CPUS and this schedule_data struct, thanks in advance

P.S. also it will be very helpful if somebody knows some site which can give quick reference about the place of definition of different structs and macro's from Linux Kernel


I'd use

cd /usr/src/linux

and browse for definitions, references, callers, callees, free text all in an ncurses gui that integrates well with the default editor

If you use vim, it's even integrated the other way around

Then there is ctags; that one is also well supported by vim and many other editors

|improve this answer|||||
  • lxr.linux.no is easier than cscope/ – osgx Apr 22 '11 at 18:59
  • 1
    well - it's different! It sure looks interesting enough if I can get it to work against other codebases – sehe Apr 22 '11 at 19:12
  • lxr was developed for linux kernel, but it is possible to use it with other projects. It is opensource. There are sites for BSD oses fxr.watson.org , for firefox mxr.mozilla.org – osgx Apr 22 '11 at 19:39
  • there is a list of existing lxr sites also en.wikipedia.org/wiki/LXR_Cross_Referencer – osgx Apr 22 '11 at 19:41
  • Also I recommend google.com/codesearch - it is google search which indexed a lot of opensource and allows to use a regex and special chars in queries – osgx Apr 22 '11 at 19:42

http://lxr.linux.no/ is online site which can find definitions and usage of any c object in linux kernel.

Just select some version of the kernel (e.g. http://lxr.linux.no/#linux+v2.6.38/ ) and paste name of variable or macro in the input field at top right.

Here, for example, result of searching NR_CPUS http://lxr.linux.no/#linux+v2.6.38/include/linux/threads.h#L20

|improve this answer|||||

NR_CPUS is defined as a macro in the file: include/linux/threads.h.

struct schedule_data is defined in: /usr/src/linux/kernel/sched.c.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy