Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

In addition to that, I'd like to see the number of SLOC for each language to get an idea how large the project is. Is this a weekend project? Is this Linux kernel?


sort by: page size:

The linux kernel is actually only about 100 K lines.

This is what I get from sloccount, which doesn't count blank lines or comments, for Ubuntu's old 3.0.0 kernel:

  Totals grouped by language (dominant language first):
  ansic:      9495321 (96.81%)
  asm:         241006 (2.46%)
  xml:          41486 (0.42%)
  perl:         13987 (0.14%)
  sh:            4117 (0.04%)
  cpp:           3486 (0.04%)
  yacc:          2987 (0.03%)
  python:        2770 (0.03%)
  lex:           1719 (0.02%)
  awk:            708 (0.01%)
  pascal:         231 (0.00%)
  lisp:           218 (0.00%)
  sed:             30 (0.00%)
Broken down by path (top 8):

  SLOC    Directory       SLOC-by-Language (Sorted)
  5474678 drivers         ansic=5469921,yacc=1688,asm=1475,perl=792,lex=779,
                          sh=23
  1848085 arch            ansic=1609109,asm=237452,sh=690,awk=470,pascal=231,
                          perl=58,python=45,sed=30
  693955  fs              ansic=693955
  518275  sound           ansic=518092,asm=183
  481158  net             ansic=481062,awk=96
  290060  include         ansic=288348,cpp=1670,asm=42
  118198  kernel          ansic=117893,perl=305
  53773   mm              ansic=53773

Overall I think your naming convention sounds reasonable; C is also my primary language. Your example was just too easy to shorten to resist ;-).

This study is from 2010 (Linux kernel 2.6.35-rc5).

The current (SDP 8) kernel has 15331 lines of code, including comments and Makefiles.

This is really cool and unique. I poked around a bit, and the kernel is vaguely POSIX like, but written in a homegrown language with a compiler written in Perl[1].

[1] https://github.com/jes/scamp-cpu/blob/f260f52d950be90c2279f5...


The first provided link is extremely useful as it lets you jump to declarations, files, and line numbers in the current Linux Kernel source. For digging up kernel code snippets it it is extremely useful.

Also like the kernel is fairly sanely laid out. Its a project with literally hundreds of contributors so keeping the code base organized is important.


Latest Linux kernel source:

      39,000  certs     0.0%
      40,000  usr       0.0%
     164,000  init      0.0%
     240,000  virt      0.0%
     250,000  ipc       0.0%
     459,000  io_uring  0.0%
     664,000  rust      0.1%
     980,000  samples   0.1%
   1,885,000  block     0.1%
   2,850,000  scripts   0.2%
   2,953,000  security  0.2%
   3,609,000  crypto    0.3%
   5,165,000  mm        0.4%
   7,156,000  lib       0.5%
  12,420,000  kernel    1.0%
  33,047,000  net       2.5%
  39,916,000  include   3.1%
  43,224,000  fs        3.3%
  45,001,000  sound     3.4%
  54,988,000  tools     4.2%
 107,971,000  arch      8.3%
 943,527,000  drivers  72.2%
Based on rough byte count (total 1,306,548,000 bytes in the above).

That's great to know! Hopefully one of these projects will make it into the kernel soon, since this is obviously a very useful feature.

Anyone know what programming language the kernel is written in?

I was also wondering this. I'm unfamiliar with linux kernel development but this reminds me of that.

Nice attention to detail! Perhaps, if you have some time later, you could read over the Linux kernel docs?

That's a surprise to me. That must be one epic mass of header files.

It reminds me of the massive Fast kernel headers patchset by Ingo Molnar. I hope it got in. I don't know anything about it, just marvelled at the scope of it.



moving on up in complexity to getting patches accepted into the main Linux kernel source tree.

Any idea how many exercises are involved. I took a class on kernel modules, and this sounds like fun, plus it is moving towards something useful, and not just a set of exercises for learning's sake.


Not the author, but the thing that got me interested in the project was some posts the author made on OSDev[0] about trying to minimize the amount of interdependencies in the libc code. A lot of the kernel is written in C++[1] which is a little rare (Haiku, and what else?). They also have a cleaned up zlib that I have used and think is quite nice[2]. Also I almost forgot about os-test[3] which tests POSIX compatibility.

[0]https://wiki.osdev.org/User:Sortie/Sortix_Thread_Local_Stora...

[1]https://gitlab.com/sortix/sortix/tree/master/kernel

[2]https://sortix.org/libz/

[3] https://sortix.org/os-test/


I'm a complete noob when it comes to kernel development -- but this seems super interesting. Anyone care to explain what's going on?

I'd love to have this in-depth level of knowledge of kernel inner workings. Super interesting writeup.

If it's using the Linux kernel, it's not mentioned anywhere. This is taking the credit from all the linux code contributors everywhere. Shame. Shame.

Nice, I'm curious how it maps the system call to the source code line number dynamically? (Edit: seems like ctags + http://elixir.free-electrons.com/linux/latest/source [1]) It supports every kernel version.

The linked source code browser seems like a useful way to check the history of system calls for research...

[1] https://github.com/thevivekpandey/syscalls-table-64bit/blob/...


I found "Linux Kernel Development" a nice overview of the kernel code: https://books.google.pt/books?id=3MWRMYRwulIC&printsec=front...
next

Legal | privacy