3

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.

3
  • 1
    Why down-vote ? Apr 8, 2013 at 9:01
  • 1
    Because you didn't do your research and kernel data structures are data structures used and defined by the kernel. Apr 8, 2013 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. Apr 8, 2013 at 9:39

2 Answers 2

4

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.

2
  • 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.
    – user
    Apr 8, 2013 at 14:33
  • 2
    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, 2013 at 15:05
3

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.

5
  • 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. Apr 8, 2013 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, 2013 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, 2013 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. :)
    – user
    Apr 8, 2013 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. Apr 9, 2013 at 4:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .