3

I want to have a go at kernel programming, mostly to understand it more, not to try to create my own OS or anything.

But I am confused as to even what language I need to program in to do this let alone what IDE(if there would be one) & compiler I can use?

I would like to attempt to interact with the Unix kernel (so thats the Linux kernel right & is this a hybrid kernel ?) or the Windows 7 kernel (thats a hybrid kernel isn't it?, the older versions of windows were Monolithic?).

If I want to get into interacting with the above mentioned kernels what language should I use & what compiler(& IDE) can I download to run my code?

Would I be looking at using c(I have done alot of win32 programming so I'm used to c & c++) or assembly for this? Also do you know of any tutorials for interacting with one of those kernels?

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
user593747
  • 1,484
  • 4
  • 32
  • 52
  • What, precisely, are you trying to do? The kernEl serves many purposes, what is your goal you're trying to achieve? (Many languages have ways of interfacing with the kernel features, e.g. with [printk](http://www.linuxchix.org/content/courses/kernel_hacking/lesson5); the actual language used won't be all that important) – Piskvor left the building Aug 11 '11 at 10:43
  • Windows kernel! This is where all those bugs come from! – Jakub M. Aug 11 '11 at 10:47
  • I want to learn about how the kernal operates. How does the kernal communicate with hardware. How does it communicate with processes(programs). Are they all just API calls like in win32 OS? I just want to learn about it because I know very little – user593747 Aug 11 '11 at 10:52
  • Get this: http://www.amazon.com/Magic-Garden-Explained-Internals-Release/dp/0130981389 – Keith Aug 11 '11 at 10:58
  • This one's probably better: http://www.amazon.com/Design-Operating-System-Prentice-Hall-Software/dp/0132017997/ref=pd_sim_b_2 – Keith Aug 11 '11 at 11:00

3 Answers3

9
  1. It is kernel, not kernal.

  2. The linux kernel is written in C. Almost all popular OS kernels are written in C.

  3. You should start with the linux kernel, as I assume you don't have access to the Windows kernel sources. Go to http://www.kernel.org and download them. Look into them. You will find documentation in the package, too.

  4. All this information can also be easily found on Google.

ypnos
  • 50,202
  • 14
  • 95
  • 141
  • 1
    Note that Symbian, eCOS and MacOS (Darwin) IO Kit subsystem are C++. C++ is maybe the only serious alternative to C if you want to do kernel work and have modern tools at your disposal (Classes, Inheritance, templates, and much more). – Erik Alapää Feb 26 '15 at 15:11
4

All depends what you mean by 'interact with the kernel'. The kernel-user interface used most often in UNIX world are the basic system calls (open, read, write) operating on files (including the device nodes in /dev and 'special files' in /proc and /sys on Linux) and these are available in virtually any language (cat /dev/random is an interaction with kernel, so the shell is 'language good enough to interact with the kernel').

Also most of the lower level system calls are available directly in most languages: ioctl, fcntl, the socket API, etc, but using those may get tricky when internal structures (originally defined in the C language) are in use.

If you want to call the system calls directly (and not the libc wrappers), your choices are generally C, C++ (not even linking with the standard library) or assembler. But going this way makes little sense even as exercise, unless you want to write your own 'libc' or something.

First decide what your goals are and what exact 'interaction' do you want, then choose the easiest solution (high level language you know). I often use Python for 'interacting with kernel' myself.

Jacek Konieczny
  • 8,283
  • 2
  • 23
  • 35
4

Linux Device Drivers is a good point to start learning kernel programming.

fresskoma
  • 25,481
  • 10
  • 85
  • 128
Sponge
  • 41
  • 1