Linux Kernel - Part 3

In this post I would like to review the function for using mmap that is introduced in Why Linux Has This Syscall?! - Tsoding His repo can be found on Github, where he demos 4 type of usage: (1) allocating memroy (2) reading files (3) IPC (inter-processing cache) (4) Precise control over memory protection Allocating Memory #include <assert.h> #include <sys/mman.h> #define N 10 int main(int argc, char *argv[]) { int *xs = mmap(NULL, N * sizeof(int), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); assert(xs != MAP_FAILED); assert(N >= 2); xs[0] = 0; xs[1] = 1; for (int i = 2; i < N; ++i) { xs[i] = xs[i - 1] + xs[i - 2]; } int err = munmap(xs, N * sizeof(int)); assert(err >= 0); return 0; } The above code request N int size memory from linux kernel through mmap, and return the virtual memory in the end by munmap. ...

August 29, 2026 · 3 min

Linux Kernel - Part 2

Recently learn more linux (materials will be put here). mmap/brk and memory allocation in C We try to build some run and use strace to analyze all the syscalls, such as execve for execution, brk and mmap for requesting the memory, etc. I notice that for the C malloc and C++ new, we actually call brk or mmap for requesting memory and then the allocator would do memory control, and it will continue requesting memory from OS if the allocator found that the current memory is not enough. ...

April 30, 2026 · 1 min

Linux Kernel - Part 1

Recently start to learn some basic stuffs for linux kernel. I’m nearly new to this since I used to study Ic desing and accelrators and has no experience in OS. The learning materials will be stored in [https://linkingmon.github.io/Algorithm/Linux](this repo). Overall I think this is interesting and I’m starting to bridge the gap for my IC design knowldege and C++ programming knowldege. Linux kernel is mostly written in C, and the interaction can be classified in 4 class: ...

April 6, 2026 · 2 min