Table of Contents

https://docs.kernel.org/index.html

Kernel headers should be copied into /usr/include to be used by libraries and compiled programs. These should be the headers glibc has been compiled against, and should be kept independent of the ones in the kernel source tree. New packages are compiled against these headers, otherwise, if packages are compiled against headers that do not match the headers glibc was compiled against, segfaults or other strange problems may appear. /usr/include headers should be what matches the library object files. By copying the headers instead of symlink them to /usr/src/<linux>/include, we make sure that they remain available if we upgrade our kernel.

Process State

Process Context

A program running in user-space executes a system call or triggers an exception, making the kernel to run in process context.

There is also interrupt context, mostly applied to when the system is executing an interrupt handler (no process is tied to interrupt handlers). Other examples are the execution of a softirq as well as initializing or running the scheduler.

The Kernel may also run kernel threads, standard processes that exist only in kernel-space, like management threads that maintain the buffer and page caches. These processes are scheduled like normal processes and are allowed to sleep.

Concurrency and shared resources

We need to keep as much local state as possible and use locking for the shared resources.

Locks

Debugging

ftp://82.96.64.7/pub/software/scm/git/docs/v1.5.0/howto/isolate-bugs-with-bisect.txt

http://www.reactivated.net/weblog/archives/2006/01/using-git-bisect-to-find-buggy-kernel-patches/

git bisect start – [path]

to restrict bisection to commits that touch [path].

http://www.av8n.com/computer/htm/kernel-lockup.htm

Porting the kernel to ARM devices

ARM11 MPCore example

ARM specific files

arch/arm/Makefile             has macros to detect machine name
         def-configs          includes the default config file
         kernel/debug.s       assembly level debugging
         lib
         boot/Makefile        lists start address from where kernel image has to be decompressed
         tools/mach-types     machine ID
         mm/proc-[CPU_TYPE]
include/asm-arm               set up functions for a specific CPU
        asm/arch/uncompress.h output kernel decompression msgs to UART
                 hardware.h   IO map of HW architecture
                 io.h         HW specific macros
                 irq.h        base address of diferent IRQs
                 irqs.h       IRQ numbers
                 time.h       time interrupt handlers and macros
                 

Contributing

Write and Submit your first Linux kernel Patch

https://kernelnewbies.org/FirstKernelPatch

https://kernelnewbies.org/Outreachyfirstpatch?action=show&redirect=OPWfirstpatch

https://tapaswenipathak.wordpress.com/2014/10/11/tools-to-cleanup-linux-kernel/

Testing

https://kernelci.org/

Useful links

https://lkml.org/

http://www.freesoftwaremagazine.com/articles/drivers_linux

http://lwn.net/Kernel/LDD3/

http://sysplay.in/blog/linux-device-drivers/2013/02/linux-device-drivers-for-your-girl-friend/