Swapping is the procedure of copying out the entire process(its address space) from main memory to some sort of secondary storage(typically hard disk or tape storage). Usually this is done as a result of CPU scheduling. Operating System typically maintains a read-to-run queue of processes. The queue comprises of information about processes that are ready... Continue Reading →
Traditional Unix Inode Block Map
I had written this answer for a number of related questions on Quora. I think the topic is worth a small article. An inode for a file maintains the complete information about physical layout of file data. This information is stored in the form of a multi-level block map. Taking the example of a Unix... Continue Reading →
Call Stack Internals (Part 1)
In this post, I will be discussing the internal working of a function call stack. The content will be divided into multiple posts for better understanding. Major focus will be on the following: Creation of stack frames, Saving/restoring registers to/from the stack. Saving function local variables, arguments, and return address on the stack. Usage and... Continue Reading →
Pre/Post Increment Operators and Performance Differences
Let's say we want to print the numbers from 0 to 9. How do we do that ? int i=0; for (i=0; i<10; i++) { printf("%d \t", i); } How about writing the same for loop as below ? int i=0; for (i=0; i<10; ++i) { printf("%d \t", i); } Is there any difference between... Continue Reading →
Singleton Design Pattern
Singleton is a design pattern for object construction. It falls under the category of "creational" design patterns. As the name somewhat suggests, it enables us to have one and only one instance of a class. This class will be a singleton class. In most cases, singleton objects are used to provide configuration settings or global... Continue Reading →
How does the free() function work?
[Sharing my answer to the above question on quora] Assuming the reader is interested in knowing the internal details of free(), I would like to explain in one of the ways I implemented it. Overall, a free() function releases a chunk of dynamically allocated memory from the heap region of the process address space. It... Continue Reading →
Advisory File Locking – My take on POSIX and BSD locks
I had a chance to do several Advisory File-Locking experiments on NFS and local file system. In this article, I would like to give some insight into the concept of advisory locking and share some useful results from my tests. Some Background File Locking is generally useful in an environment where multiple applications or processes may... Continue Reading →
What is the difference between scaling horizontally vs scaling vertically? How can this affect the design decisions that are made?
[Sharing my answer to the above question on Quora] Horizontal Scaling - also referred to as "scale-out" is basically the addition of more machines or setting up a cluster or a distributed environment for your software system. This usually requires a load-balancer program which is a middle-ware component in the standard 3 tier client-server architectural... Continue Reading →
Static and Dynamic Linking (Part I)
Linking is the process of combining multiple object files into a single executable that can be used to start the application. Linking is the last phase of compilation process and deals with the object files(binary) rather than actual source code files. Object files are binary in nature and contain the assembly language representation of all... Continue Reading →