Operating System Important Interview Question

Asleep state means (Blocked in Memory)

Waiting for I/O or event

Still in memory (RAM)

Sleep (Swapped) process

Blocked + not in memory

Waiting + swapped to disk (RAM to disk)

Zombie process

Process finished execution

Still has entry in process table (waiting for parent to collect status)

Summary: UNIX process model extends basic states by adding kernel mode, swapping, and zombie state to handle real OS complexities.

Normal model ends at Terminated, while OS (UNIX) keeps a Zombie state until the parent collects the process status.

If the parent itself terminates, the child is adopted by init (PID 1), which automatically collects it removing the zombie.

init: First process (PID 1) that adopts orphan processes and cleans zombies.

systemd: Modern replacement for init that manages services and system startup.

Orphan Process: Child whose parent has terminated; adopted by init/systemd.

Daemon Process: Background process running without user interaction (e.g., servers).

e xec: Replaces the current process’s memory with a new program while keeping the same process ID (PID).

Aging: Gradually increasing priority to prevent starvation. Aging is used to reduce starvation of low priority tasks.

Affinity (CPU Affinity): Binding process to a specific CPU for performance.

Livelock: Processes keep changing state but make no progress.

T he fraction of time CPU is busy = service time / staying time .

Deadlock situations occur when four conditions occur simultaneously in a system : M utual exclusion , H old and Wait , N o preemption , C ircular wait.

Banker’s algorithm is one form of deadlock-avoidance in a system.

Overlays are used to run programs larger than available RAM by loading only required parts into memory at a time. They help optimize memory usage and avoid loading unnecessary code , improving efficiency in memory-limited systems.

Trashing refers to an instance of high paging activity . This happens when it is spending more time in paging instead of executing .

Root partition is where the operating system kernel is located . It also contains other potentially important system files that are mounted during boot time.

The first Real-Time Operating System (RTOS) is generally considered to be VRTX (Versatile Real-Time Executive), developed in the 1980s .

ISRO (Space Applications) : Uses RTEMS (Real-Time Executive for Multiprocessor Systems) .

How would a filenamed EXAMPLEFILE.TXT appear when viewed under the DOS command console operating in Windows 98? Ans: The filename would appear as EXAMPL~ 1.TXT . The reason behind this is that filenames under this operating system is limited to 8 characters when working under DOS environment.

Monolithic Kernel: All operating system services ( memory management, file system, device drivers, etc.) run together in a single large kernel space , resulting in high performance but less modularity.

Microkernel: Only essential services (like scheduling and communication) run in the kernel , while other services run in user space, making it more modular, secure, and easier to maintain but slightly slower due to communication overhead.

Bootstrapping: The process of starting a computer by loading the operating system into memory using a small initial program (bootloader) stored in ROM.

RAID (Redundant Array of Independent Disks): A technique that combines multiple physical disks into a single logical unit to improve performance, reliability, or both.

Hardware RAID uses a dedicated controller card or onboard chipset to manage the array, offloading parity computation from the host CPU. Software RAID uses the OS kernel — Linux mdadm .

RAID 0 - Non-redundant striping: This level is used to increase the performance of the server.

RAID 1 - Mirroring and duplexing: This level is also known as disk mirroring and is considered the simplest way to implement fault tolerance.

RAID 2 - Memory-style error-correcting codes: This level generally uses dedicated hamming code parity i .e., a liner form of error correction code.

RAID 3 - Bit-interleaved Parity: This level requires a dedicated parity drive to store parity information.

RAID 4 - Block-interleaved Parity: This level is similar to RAID 5 but the only difference is that this level confines all parity data to a single drive.

RAID 5 - Block-interleaved distributed Parity: This level provides far better performance than disk mirroring and fault tolerance.

RAID 6 - P+Q Redundancy: This level generally provides fault tolerance for two drive failures.

BIOS : It initializes hardware during booting and provides runtime services for the OS.

FAT is a table used by the OS to map files to physical disk sectors.

Swapping is the process of moving a process temporarily out of main memory to a storage device (usually disk) and bringing it back later to resume execution. It helps free up memory for other active processes when there is insufficient RAM.

Belady’s Anomaly occurs in some page replacement algorithms (like FIFO), where increasing the number of page frames leads to more page faults instead of fewer.

A hypervisor, or virtual machine monitor, allows multiple operating systems to run on the same hardware by managing their resource allocation. Examples include VMware and VirtualBox.

Bare-metal programming refers to writing software that runs directly on hardware without an operating system , giving full control over system resources and ensuring high performance and real-time responsiveness.

A Resource Allocation Graph (RAG) is a graphical representation used to detect deadlocks in a system. It shows processes and resources as nodes, with edges representing the allocation or request of resources. A cycle in this graph indicates a potential deadlock .

A monitor is a high-level synchronization construct that allows safe and structured access to shared resources . It provides mechanisms like locks and condition variables to control access to critical sections.

External Fragmentation: Occurs when free memory is scattered, and a process cannot be allocated due to lack of a contiguous block. Real-life example: Like a parking lot with many small empty spaces where a large bus cannot park because no single continuous space is big enough .

Internal Fragmentation: Occurs when allocated memory is larger than required , leaving unused space inside the block. Real-life example: Like booking a big hotel room for one person, where part of the room remains unused .

Inode (i-node): A data structure that stores all file information (size, permissions, location) except the file name ; Hard link points to the same inode (same file data), while soft link stores the file path (acts like a shortcut).

Thread Pool: A collection of pre-created threads that are reused to execute multiple tasks , reducing the overhead of creating and destroying threads each time .

Spooling: A technique where data is temporarily held in a queue (usually on disk) until the device is ready to process it. It is often used in printer management.

Buffering: A technique where data is temporarily stored in memory before it is processed or written to the disk, helping to smooth out differences in data processing speeds.

What is cache-coherency? In a multiprocessor system there exist several caches each may containing a copy of same variable A. Then a change in one cache should immediately be reflected in all other caches this process of maintaining the same value of a data in all the caches s called cache-coherency.

Early operating systems were called residence monitors.

P-thread refers to the POSIX standard (IEEE 1003.1c) defining an API for thread creation and synchronization. This is a specification for thread behavior, not an implementation. The windows OS have generally not supported the P-threads.

Paging is solution to external fragmentation problem which is to permit the logical address space of a process to be noncontiguous , thus allowing a process to be allocating physical memory wherever the latter is available.

DHCP stands for Dynamic Host Configuration Protocol. It automatically assigns IP addresses and other network details such as subnet mask, gateway, and DNS server to client devices .

The purpose of DHCP is to reduce manual IP configuration , avoid IP address conflicts, and make network management easier.

NFS (Network File System) is a distributed file system protocol that allows a user on a client machine to access files over a network just like local files.

To share files and directories between Red Hat Linux and Microsoft Windows means configuring a Samba Server on Linux so that Windows systems can access Linux files over the network.

Samba is an open-source software that implements the SMB (Server Message Block) and CIFS (Common Internet File System) SMB/CIFS protocol, allowing file and printer sharing between Linux and Windows systems.

Domain Name System (DNS) is a system that converts human-readable domain names into IP addresses.

In paging, there is no external fragmentation because the page size is equal to the frame size. However, internal fragmentation may exist in the last page because the process size may not completely fill the allocated page frame. On average, the internal fragmentation in paging is considered as half of a page, i.e., , where represents the page size.

Translation Lookaside Buffer (TLB) is added to improve the performance of address translation in paging. The TLB contains frequently referred page numbers and their corresponding frame numbers, which helps in reducing memory access time. It is a hardware device implemented using associative registers. The TLB is placed before the page table so that frequently used page table entries can be accessed quickly without searching the complete page table in main memory.

To avoid the overhead of maintaining a large page table size, multilevel paging is implemented. In multilevel paging, paging is applied to the page table itself. Instead of bringing the entire page table into the main memory (RAM), only the required pages of the page table are loaded into memory from secondary memory (disk). This reduces memory consumption and improves the efficiency of memory management.

In normal paging, every process has its own separate page table, and these page tables are stored in the main memory (RAM). This means each process maintains its own mapping between pages and frames.

However, maintaining separate page tables for every process increases memory overhead, especially when many processes are running. To solve this problem, inverted paging is introduced. In inverted paging, instead of keeping one page table per process, the operating system maintains only one global page table for the entire system in main memory. This single table stores entries for all processes along with process identifiers and frame information.

So, normal paging uses separate page tables for each process, whereas inverted paging uses one common page table for all processes to reduce memory usage.

Paging does not follow the user’s view of memory allocation because the logical address space is divided into fixed-size pages. To achieve the user’s view of memory allocation, segmentation is implemented. In segmentation, the logical address space (LAS) is divided into various segments such as code segment, data segment, and stack segment. The size of segments can vary, whereas in paging the page size is fixed. The number of entries in the segment table is equal to the number of segments in the logical address space. These variable-sized segments are brought from the logical address space (LAS) to the physical address space (PAS). Since segmentation uses variable-sized memory allocation, it behaves similarly to variable partition memory allocation and therefore suffers from external fragmentation .

The main goal of POSIX is to make software portable , so a program written for one POSIX-compliant operating system can run on another with minimal changes . Functions like fork(), exec(), pthread_create(), and commands like ls, cp, and grep follow POSIX standards.

The grep command in Linux and UNIX is used to search text or patterns inside files. grep stands for:

Global Regular Expression Print Example: grep "hello" file.txt

Privileged instructions are those instructions that can be executed only by the Operating System kernel in kernel mode (supervisor mode).

Non-privileged instructions can be executed by both user programs and the operating system in user mode.

When the power button is pressed, the SMPS (Switched Mode Power Supply) powers the hardware, and the CPU (Central Processing Unit) starts executing instructions from BIOS (Basic Input Output System) or UEFI (Unified Extensible Firmware Interface).

The system performs POST (Power-On Self-Test), loads the bootloader such as GRUB, initializes the Operating System kernel, and finally displays the login screen or desktop.

init process is ancestor of all processes.

When a parent process creates a child process using fork(), both run the same program at first. The child process can then use exec() to replace its program with another executable. So, the child can run a different program from the parent.

fork system call creates new process . The new process is an exact copy of the parent and continues execution from the same point as its parent. Exec system call used after a fork to replace the processes memory space with a new program .

exit() system call is used by most operating systems for process termination . Process resources are deallocated by OS .

Parents may terminate execution of children process via kill() function.

Pipe is widely used for communication between two related processes . This is a half-duplex method, so the first process communicates with the second process. However , in order to achieve a full-duplex, another pipe is needed .

A dump is a copy of data or memory taken from a computer system for analysis, backup, or debugging purposes. It usually stores the contents of memory, files, or a database at a particular moment.

Solaris is a UNIX-based operating system developed by Sun Microsystems, later owned by Oracle. It is mainly used in servers, workstations, database systems, and enterprise environments.

Virtual memory gives an illusion to the programmer that programs larger than the actual physical memory can be executed.

Example:

If physical address space (PAS) = 100 KB and program size = 200 KB, then the program can still be executed with the help of virtual memory.

Virtual memory can be implemented using:

Demand Paging

Demand Segmentation

(Generally, operating systems mainly follow demand paging as the memory management technique.)

A page fault occurs when the CPU tries to access a page, but that page is not available in the main memory (RAM). In this situation, the operating system loads the required page from secondary memory into main memory, and then execution continues.

Demand paging is a memory management technique in which a page is loaded into the main memory (RAM) only when a page fault occurs. The time taken to handle and service a page fault is called page fault service time.

Belady’s anomaly is a condition in paging where increasing the number of page frames causes an increase in the number of page faults instead of decreasing them. This unexpected behavior is known as Belady’s anomaly.

Locality of Reference

Locality of reference is the tendency of a program to access the same memory locations or nearby memory locations repeatedly within a short period of time. It improves the performance of cache memory and virtual memory because recently used or nearby data is likely to be accessed again.

Types of Locality of Reference

Temporal Locality: If a memory location is accessed once, it is likely to be accessed again in the near future. Example: variables used inside loops.

Spatial Locality: If a memory location is accessed, nearby memory locations are also likely to be accessed soon. Example: accessing elements of an array sequentially.

Sequential Locality: Memory locations are accessed in a sequential order, one after another. Example: execution of program instructions line by line.

In the buddy system, memory is initially available as a single large continuous free block. When a process requests memory, the block is divided into two equal halves, and if the required size is still smaller, the smaller block is again divided into two equal half blocks until a suitable block size is obtained. Thus, memory is allocated by repeatedly splitting larger blocks into smaller buddy blocks according to the process requirement.