Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Diksha Patro
Page 3 of 10
Mimic the Linux adduser command in C
The adduser command in Linux is used to add new user accounts on Unix-like operating systems. System administrators frequently use it to create new users with predetermined usernames, passwords, and other user-related information. This article demonstrates how to mimic this functionality using C programming and system calls. System Calls Overview System calls allow software to communicate with the operating system kernel, which manages system resources and provides services to user-level programs. In C programming, system calls provide access to OS features including file I/O, process management, and network connectivity. Essential System Calls open − Opens or ...
Read MoreNumerical on LRU, FIFO
In this article, we will explore LRU (Least Recently Used) and FIFO (First In First Out) page replacement algorithms through detailed numerical examples, examining their step-by-step execution and practical applications. Least Recently Used Algorithm The LRU (Least Recently Used) algorithm is a popular page replacement strategy used in operating systems and cache management. When the cache is full and a new page needs to be loaded, LRU replaces the page that has been accessed least recently, based on the principle that recently accessed pages are more likely to be accessed again. LRU Numerical Example Given: Cache ...
Read MoreLinked List for Dynamic Partitioning
A linked list is made up of nodes, each containing a data element and a pointer to the next node in the list. In dynamic partitioning, each node represents a memory block that can be allocated to processes. The linked list initially represents the entire available memory as a single large block. Dynamic Partitioning in Memory Management Dynamic partitioning is a memory management technique that divides memory into variable-sized segments to accommodate multiple processes simultaneously. Unlike fixed partitioning, it allocates exactly the amount of memory each process needs, minimizing waste. Dynamic Memory Partitioning ...
Read MoreLinux System Call in Detail
A system call is a mechanism in Linux that allows user-space applications to interact with the kernel, which forms the core of the operating system. When a user-space application needs privileged operations performed—such as reading/writing files or creating new processes—it must request these services from the kernel through system calls. How Linux System Calls Work System calls are executed in kernel mode and accessed by user-space applications through standard C library functions like open(), read(), write(), close(), fork(), and exec(). System Call Execution Flow ...
Read MoreLock Variable Mechanism
A lock variable is a fundamental synchronization mechanism that controls access to shared resources in multi-threaded or multi-process environments. It acts as a simple data structure, typically implemented as a boolean or integer, that indicates whether a resource is currently in use or available for access. How Lock Variable Mechanism Works When a thread or process wants to access a shared resource, it first checks the lock variable's value. If the lock is free (unlocked), the thread can acquire it by setting the variable to busy (locked). This ensures mutual exclusion, allowing only one thread to access the ...
Read MoreLogical Clock in Distributed System
Logical clocks in distributed systems provide a way to order events across multiple machines that do not share synchronized physical clocks. Since each machine may have its own local clock running at different rates, logical clocks assign timestamps to events based on causality rather than actual time, creating a consistent virtual global timepiece across all machines in the system. The Need for Logical Clocks In distributed systems, establishing the order of events is crucial for maintaining consistency. Physical clocks on different machines may drift or run at different speeds, making it impossible to rely on wall-clock time for ...
Read MoreLRU Approximation (Second Chance Algorithm)
The LRU Approximation Algorithm, commonly known as the Second Chance Algorithm, is a page replacement algorithm used in operating systems for memory management. It provides an efficient approximation to the ideal Least Recently Used (LRU) algorithm while maintaining significantly lower overhead. This algorithm uses reference bits and a circular queue structure to make replacement decisions. How the Second Chance Algorithm Works The algorithm maintains pages in a circular queue and uses a single reference bit per page. When a page fault occurs, the algorithm searches for a victim page to replace using the following process: Start ...
Read MoreLRU Cache implementation using Double Linked Lists
LRU (Least Recently Used) Cache is a caching algorithm that evicts the least recently accessed item when the cache reaches its capacity. It maintains items in order of their usage, with the most recently used at the front and the least recently used at the back. A doubly linked list combined with a hash map provides an efficient implementation with O(1) time complexity for both get and put operations. How LRU Cache Works The LRU cache maintains two key data structures: Doubly Linked List − Stores cache items in order of usage, with head as most ...
Read MoreMaekawa\'s Algorithm for Mutual Exclusion in Distributed System
Multiple processes may require concurrent access to common resources in a distributed system. Concurrent access to a shared resource, however, may result in errors and inconsistencies. A distributed mutual exclusion algorithm must be employed to manage access to shared resources in order to guarantee mutual exclusion. Maekawa's Algorithm is a distributed mutual exclusion technique that ensures mutual exclusion between running processes in a distributed system. Only one process at a time can access a shared resource thanks to the algorithm, which is based on a voting system. How Maekawa's Algorithm Works The voting-based algorithm was proposed in ...
Read MoreMaster Boot Record
The Master Boot Record (MBR) is a critical 512-byte sector located at the very beginning of a storage device such as a hard disk drive or SSD. It contains essential information required to start the computer's boot process and load the operating system. The MBR consists of three main components: boot code, partition table, and disk signature. MBR Structure and Organization Master Boot Record (512 bytes) Boot Code (446 bytes) Partition Table (64 bytes) ...
Read More