Concurrency and Its Management Race condition can often lead to system crashes, memory leak,corrupted data,or security problem as well avoid the use of global variables The Linux Semaphore Implementation Semaphore #include <linux/semaphore.h> void s…
kmalloc #include <linux/slab.h> void *kmalloc(size_t size,int flags); void kfree(void *addr); flags: GFP_ATOMIC: Used to allocate memory from interrupt handlers and other code outside of a process context.Never sleeps GFP_KERNEL: Normal allocation o…
Measuring Time Lapses The counter and the utility functions to read it live in <linux/jiffies.h>.Needless to say both jiffies and jiffies_64 must be considered read-only. Processor-Specific Registers #include <asm/msr.h> rdtsc(low32,high32); r…
ioctl //user space int ioctl(int fd,unsigned long cmd,...); //kernel space int (*ioctl)(struct inode *inode,struct file* filp,unsigned int cmd,unsigned long arg) Blocking I/O #include <linux/wait.h> wait_queue_head_t my_queue; DECLARE_WAIT_QUEUE_HEA…
## Linux kernel memory-faq.txt What is some existing documentation on Linux memory management? Ulrich Drepper (the ex-glibc maintainer) wrote an article series called "What every programmer should know about memory": Part 1: http://lwn.net/Artic…
https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The configuration database is a collection of configuration options organized in a tree structure: +- Code maturity level options | +- Prompt for developme…
Linux kernel coding style | Linux内核编码风格 This is a short document describing the preferred coding style for the linux kernel. Coding style is very personal, and I won't force my views on anybody, but this is what goes for anything that I have to be ab…
In this blog post we'll go over a Linux kernel privilege escalation vulnerability I discovered which enables arbitrary code execution within the kernel. The vulnerability affected all devices based on Qualcomm chipsets (that is, based on the "msm&quo…
http://en.wikipedia.org/wiki/Ingo_Molnár http://zh.wikipedia.org/wiki/英格·蒙內 Ingo Molnár Ingo Molnár, currently employed by Red Hat, is a Hungarian Linux hacker. He is best known for his contributions to the operating system in terms of security and p…
Linux Kernel中所應用的數據結構及演算法 Basic Data Structures and Algorithms in the Linux kernel Links are to the source code on github. Linked list, doubly linked list, lock-free linked list. B+ Trees with comments telling you what you can't find in the textbooks…
本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码片段(不关注OS的各个模块的设计思想,此部分我准备写在“深入理解Linux Kernel” 系列文章中),一来通过内核代码复习一下C语言及汇编语言的语法,二来学习内核开发大牛们书写代码的风格及思路. 在内核文件 include/linux/bug.h中,有下面两行的宏定义: 1 2 3 4 5 6 /* Force a compilation error if condition is true, but al…
Because there are numerous revisions and releases of the Linux kernel and new ones are developed at frequent intervals, it is important to have a system for clearly identifying them. A kernel is a program that constitutes the central core of a comput…