Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

While reading about the Linux kernel I came across the notion of kernel data structures. I tried to find more information via Google, but couldn't find anything.

  • What are kernel data structures?
  • What are their requirements, usage, and access?
  • What's the organization of data structure inside the kernel?

Examples of kernel data structures might be file_operations or c_dev.

share|improve this question
    
Why down-vote ? –  Karthi prime Apr 8 '13 at 9:01
1  
Because you didn't do your research and kernel data structures are data structures used and defined by the kernel. –  Ulrich Dangel Apr 8 '13 at 9:18
    
i wanted more information than that. Couldn't find those. Did tried my best. Might be I shouldn't have added What are kernel data structure part. –  Karthi prime Apr 8 '13 at 9:39

2 Answers 2

up vote 2 down vote accepted

The kernel is written in C. "Kernel data structures" would just refer to various formations (trees, lists, arrays, etc.) of mostly compound types (structs and unions) defined in the source, which C code is normally filled with stuff like that. If you don't understand C, they will not be meaningful to you.

Data structures structure the storage of information in memory or address space. There is nothing particularly special about the ones used by the linux kernel. Some of them can/must be used if you are writing a kernel module, but their use is completely internal to the kernel. Kernel memory is only accessed by the kernel and it's structure has no relevance to anything else.

share|improve this answer
    
Note that data structures does not imply using anything like C's struct construct. It probably is a common way to do it, but it isn't the only way to achieve that goal. –  Michael Kjörling Apr 8 '13 at 14:33
    
Absolutely, "data structures" is a general term that is often used in a language agnostic way. But in the context of the linux kernel, which is written in C (and asm, but I don't think that matters on this level), "data structures" are mostly amalgamations of structs. I'll clarify that since it more properly would refer to the amalgamations (trees, lists, arrays, etc.), although, except for arrays, those are themselves usually defined as types via struct. –  goldilocks Apr 8 '13 at 15:05

The kernel keeps track of the state of the system - existing user processes, allocated memory, status of processors, loaded device drivers, status of hardware, cached I/O, network ports, timers, even performance metrics. Basically anything that is a system resource and not part of a user process, and not part of the kernel program itself.

All of this information are stored in "kernel data structures", which is just memory which stores records formatted in defined ways.

Usually you encounter this word when you read about kernel debugging, tracing, or kernel dumps. A kernel dump can copy out only the kernel structures, or the kernel structures as well as the process/user data. Most of the time you just need the kernel data structures.

share|improve this answer
    
Does Kernel data structure uses memory in RAM? => volatile? While booting process it creates its first kernel data structure? Is there any kernel data structure table? Too many questions might be daunting. –  Karthi prime Apr 8 '13 at 9:36
1  
Do you know what the kernel is and does? If not, learn that first before you worry about how it works internally. –  Useless Apr 8 '13 at 10:17
    
Yes Kernel Data Structures exist in physical ram. Some are created during the boot process, some are specific to loadable modules which are loaded later on. I just Googled "Kernel Data Structures" and found two good resources on the first page: cs.nyu.edu/courses/fall06/G22.2245-001/syll/lect3.pdf and tldp.org/LDP/tlk/ds/ds.html –  Johan Apr 8 '13 at 10:19
1  
I don't have the rep to make "trivial" edits, but it's cached I/O, not cashed I/O. Cash is money, cache is something else. :) –  Michael Kjörling Apr 8 '13 at 11:45
    
I read about kernel and got some electric shock in me. I never thought kernel has to maintain the data-structures, apart from scheduling. –  Karthi prime Apr 9 '13 at 4:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.