Category: Linux internals

Linux Memory Management Tricks

Tips to Improve Dynamic Memory Performance Instead of using memset() to initialize malloc()’ed memory, use calloc(). Because when you call memset(), VM system has to map the pages in to memory in order to zero initialize them. It’s very expensive and wasteful if you don’t intend to use the pages right away. calloc() reserves the…

Netlink Sockets: Linux Kernel-User communication (PART I)

Ubuntu 14.04, Kernel version 3.11 Netlink sockets provide full duplex, asynchronous, low-overhead communication channel between user-kernel space processes. Other solutions such as ioctl(), sysfs, UDP sockets are either blocking (hence expensive) or slow (UDP has more overhead compared to Netlink) and complex. Netlink can carry data buffers on a return trip from kernel to user…

Linux Device Driver Development: Block Device Driver

It is my very first interaction with Linux kernel at device driver level. My objective is to develop a block device driver, very simple, that just forward I/O requests to a virtual device. This post explains my observations limited to attacking the problem. Block v/s Character Device Linux support block and character device drivers. Only…

Linux FUSE Internals for developers

In this post, I will cover FUSE internals for FUSE 2.9.3. Install package fuse and fuse-devel on CentOS. getattr() is a must in a FUSE file-system. Any lame implementation is okay; Just be careful of the file size in stat structure. If you forgot to compile user file system with 64-bit flags on. Otherwise the…

Linux kernel: interesting optimizations

gettimeofday() Every process has a read-only page mapped to its address space. This page is at a fixed location and keeps value of time, updated at every tick of clock. Since page is mapped into process memory, no system call is required. Process can directly read the page. This page is called vsyscall page and…

Ubuntu on a Windows host: Alternative to VirtualBox and VMWare

Wubi is a cool alternative to VMPlayer and VirtualBox to run Ubuntu “almost” natively on your Windows system. It gives you a dual boot machine without partitioning your filesystem. How to do it • Install Wubi • Plave your Ubuntu ISO in the _same_ place where your Wubi binaries are • Install Ubuntu from Wubi…

Android OS: Google DVM and Virtual machines

Published in LinuxForYou, Jun 2011 Abstract With the outburst of heterogeneous systems, the need for a scalable software system is very much required without compromising the cost of development and maintenance of the software. Virtual machine (VM) provides abstraction from the heterogeneity and presents a low cost and scalable software development environment. VM based modern…

How tail -f work?

“tail -f” is a special command in a way that it polls the specified file for any change and prints the new stuff on the fly. It is very helpful in observing logs and any event based data. Ever wondered how tail achieves this? “tail” opens the given file and obtains the file-descriptor. It opens…

>Linux Scheduling: A Few Facts

>- Linux scheduler favors I/O bound processes. It uses dynamic priorities to schedule processes. So a process that has not got CPU for a long time, would get its priority increased and vice verse. – Processes are moved to different queues and al processes on ready queue are assigned an ‘epoch’. The epoch is relevant…