Popular
Data Science
Technology
Finance
Management
Future Tech
Preparing for an interview about operating systems (OS) can be difficult. OS concepts are fundamental to understanding how software interacts with hardware. The function of operating systems is to manage hardware resources, develop a platform for executing applications and ensure efficient performance of the system. OS subjects are a common focus during technical interviews because they are fundamental to any software development or IT job.
This guide covers essential questions on process management, memory management, file systems as well as security. Additionally, example answers will be provided to help you prepare fully and ensure that you handle questions related to OS effectively during your interview.
An Operating System is a computer program that controls both the computer hardware devices and software resources. The operating system works between the programs and users of one side and the hardware components of the computer on the other side by offering the common services, which computer programs utilize. Examples include Windows, macOS or Linux.
The main functions of an operating system include:
Function | Description |
Process Management | Manages the execution of processes, including multitasking and scheduling. |
Memory Management | Allocates and manages the computer’s memory resources. |
File System Management | Controls the creation, deletion, and access of files and directories. |
Device Management | Manages device communication via drivers. |
Security and Access Control | Protects data and resources from unauthorised access. |
Feature | Multiprogramming | Multitasking | Multiprocessing |
Definition | Multiple programs are loaded in memory, and the CPU is switched between them to increase efficiency. | Multiple tasks are performed concurrently by switching rapidly between them. | Multiple processors (CPUs) are used to perform tasks simultaneously. |
Objective | Maximise CPU utilisation | Provide responsive interaction | Improve performance and reliability by parallel processing |
Example | Running a batch job while a user program runs | Running a web browser and a text editor at the same time | Running multiple complex computations or server processes concurrently |
Execution | Single CPU switches between programs | Single CPU switches between tasks frequently | Multiple CPUs execute different processes simultaneously |
Complexity | Moderate | Moderate | High |
Resource Usage | Efficient memory usage, high CPU utilisation | High CPU and memory usage | High CPU usage with efficient distribution of tasks |
Context switch refers to a process whereby CPU state storage is done in such a way that multiple processes are enabled to share a single CPU resource. When context switching takes place, it enables the OS to jump from one task to another, ensuring efficiency in multitasking or execution of other critical functions within a PC system. During the context-switching process, information like registers or program counters would be saved into the process table before being loaded into the new state of the next running process.
A process is a program in execution, including its code, data, and resources. It is an active entity with a unique Process ID (PID). The process table is a data structure maintained by the operating system that keeps track of all the processes. It contains information such as the process state, PID, program counter, and memory allocation.
Field | Description |
Process ID (PID) | Unique identifier for the process |
Process State | Current state (running, waiting) |
Program Counter | Address of the next instruction |
Memory Allocation | Memory used by the process |
A thread is the smallest unit of a process that can be scheduled and executed by the CPU. It is a path of execution within a process and shares the process’s resources, such as memory and open files. Multiple threads can exist within a single process, enabling parallelism and efficient task management.
Feature | Process | Thread |
Definition | An independent program in execution. | A lightweight sub-process or task within a process. |
Memory | Each process has its own memory space. | Threads share the same memory space within a process. |
Resource Overhead | High, as each process has its own resources. | Low, as threads share resources of the process. |
Communication | Inter-process communication (IPC) needed. | Direct communication through shared memory. |
Creation Time | Longer, due to resource allocation. | Shorter, as resources are already allocated. |
Process Creation:
Process Termination:
Feature | Preemptive Scheduling | Non-Preemptive Scheduling |
Definition | The OS can interrupt and switch tasks. | The OS waits for the running task to finish. |
Control | The OS has control over task switching. | The running task has control over its completion. |
Response Time | Lower, due to quick task switching. | Higher, as each task runs to completion. |
Complexity | Higher, due to handling interruptions. | Lower, as tasks run without interruptions. |
Example | Round Robin, Shortest Remaining Time First (SRTF) | First-Come, First-Served (FCFS), Shortest Job Next (SJN) |
System Calls:
Normal Function Calls:
Feature | System Calls | Normal Function Calls |
Access Level | Kernel mode | User mode |
Purpose | Request services from the OS | Perform specific tasks within a program |
Execution Overhead | Higher, due to context switching to kernel | Lower, executed within the same user space |
Examples | open(), read(), write() | printf(), strlen(), sort() |
Feature | Kernel Mode | User Mode |
Access Level | Full access to all system resources | Limited access to system resources |
Privileges | High, can execute privileged instructions | Low, cannot execute privileged instructions |
Purpose | Execute OS code and manage hardware | Execute application code |
Stability | Less stable, errors can crash the system | More stable, errors are confined to the application |
Example | System calls, device drivers | User applications, standard library calls |
Thrashing refers to the constant swapping of pages in and out of memory while the actual processes are not being executed because the system is busy. It normally results from a shortage in RAM, which degrades the performance of a system.
Benefit | Description |
Responsiveness | Improves application responsiveness by allowing background tasks to run concurrently. |
Resource Sharing | Threads within a process share resources, which is more efficient than separate processes. |
Scalability | Utilises multiprocessor architectures more effectively by running threads in parallel. |
Simplified Program Structure | Easier to manage multiple tasks within a single application context. |
Any temporary storage section that is used as an intermediate in withholding data during its movement from one location to another is known as a buffer. Buffers are used to manage data streams and improve data transfer efficiency between devices or processes.
Demand paging is a memory management technique wherein the memory loads only the pages of data when required instead of loading all pages in advance. Hence, it does not congest the memory and hence speeds up the performance of a system.
State | Description |
New | The process is being created. |
Ready | The process is waiting to be assigned to a CPU. |
Running | The process is currently being executed by the CPU. |
Waiting | The process is waiting for an event (e.g., I/O completion). |
Terminated | The process has finished execution or has been terminated by the OS. |
Suspended | The process is temporarily stopped, possibly swapped out to disk. |
Scheduling Algorithm | Description |
First-Come, First-Served (FCFS) | Processes are executed in the order they arrive. |
Shortest Job Next (SJN) | Processes with the shortest execution time are scheduled next. |
Priority Scheduling | Processes are scheduled based on priority levels. |
Round Robin (RR) | Each process gets a fixed time slice in a cyclic order. |
Multilevel Queue Scheduling | Processes are divided into multiple queues based on their priority and type. |
Shortest Remaining Time First (SRTF) | A preemptive version of SJN, where the process with the least remaining time is scheduled. |
The highest utilisation of the CPU by running several processes together is the goal of multiprogramming. In that case, it always keeps the CPU busy with the execution of any process to enhance efficiency and throughput.
Without an OS, computer systems face several problems, including:
First-Come, First-Served (FCFS) scheduling algorithm executes processes according to their arrival order in the ready queue. It has an easy validation process because it only needs proportionate waiting times, but in some scenarios, it results in a convoy effect, causing slow response due to long tasks with small ones behind them.
Round Robin (RR) Scheduling Algorithm allocates a fixed time slot, (Time Quantum) for every process in the ready queue. The CPU cycles through processes giving each one a turn to execute for quantum duration. This ensures fairness, leading to better response time but may result in massive context switching overheads.
Caching is the process of putting frequently used data in a temporary storage area to make access to data more rapid. This latency-reducing and performance-enhancing function can be found either at higher or lower levels of computing.
An assembler translates assembly language into machine code that a computer’s CPU can directly execute. This allows us to use mnemonics and symbols that are later translated to the corresponding binary opcode and addresses, making low-level programming possible.
A graphical user interface, or GUI, is a computer environment wherein a human can interact with the computers through windows, icons, buttons, and menus-instead of typing command lines. GUIs make software more usable and accessible by providing intuitive graphical controls that allow users to quickly painlessly complete their intended tasks.
Pipes use unidirectional flow when passing information from one process to another in inter-process communication. Pipes are commonly used for connecting the output from one process to the input of another thus enabling sharing of data and task chaining in an efficient manner.
Goal | Description |
Fairness | Ensure all processes get a fair share of CPU time. |
Efficiency | Maximise CPU utilisation and minimise idle time. |
Response Time | Minimise the time from submission to the first response. |
Turnaround Time | Minimise the total time from submission to completion of a process. |
Throughput | Maximise the number of processes completed per unit time. |
Predictability | Ensure consistent and predictable process performance. |
A bit vector is a vector in which each element is a bit – thus, its value is either 0 or 1. In most vectors, each element is in a distinct address in memory and can be manipulated independently from the rest of the elements, and we also hope to be able to perform “vector operations” that treat all elements uniformly. One application of bit vectors is in encoding information in a computer system; for example, numbers are represented using bit vectors.
Rotational latency is the delay experienced while waiting for the desired disk sector to rotate under the read/write head. It is a component of the total disk access time, along with seek time and data transfer time.
A File Allocation Table (FAT) is a file system structure used to keep track of the clusters (storage units) on a disk. It maps each file to its corresponding clusters, allowing the system to locate and manage files efficiently. FAT is used in various file systems, including FAT12, FAT16, and FAT32.
Deadlock Recovery Method | Description |
Process Termination | Terminate one or more processes involved in the deadlock. |
Resource Preemption | Temporarily take resources away from processes and relocate them. |
Rollback | Roll back one or more processes to a safe state before the deadlock occurred. |
Deadlock Detection and Resolution | Continuously check for deadlocks and resolve them using one of the above methods. |
Real-time systems refer to computer systems that must respond quickly and precisely at times dictated by external events. Such systems are meant for processing data within hard constraints with regard to timing, they are popularly used in areas like embedded systems, industrial control, mission-critical tasks etc.
Seek time is the duration that a hard disk drive (HDD) takes to find and move a read or write head from one track to another where necessary data has been stored. It contributes significantly to the performance of hard disk access as its value forms a part of the total disk access time.
RAID Level | Description |
RAID 0 | Data striping without redundancy, improves performance but no fault tolerance. |
RAID 1 | Data mirroring, duplicates data on two disks for fault tolerance. |
RAID 5 | Data striping with distributed parity, provides fault tolerance and efficient storage. |
RAID 6 | Similar to RAID 5 but with an extra parity block, allows for up to two disk failures. |
RAID 10 | Combines RAID 1 and RAID 0, mirroring and striping for high performance and fault tolerance. |
RAID 50 | Combines RAID 5 and RAID 0, providing fault tolerance and high performance. |
RAID 60 | Combines RAID 6 and RAID 0, offering enhanced fault tolerance and performance. |
Banker’s algorithm is a deadlock-avoidance algorithm. It allocates resources based on resource needs of each process, then determines if the state is safe in terms of deadlock avoidance. If the system remains in safe state after allocation, the resources are allocated; otherwise make it wait.
Dynamic loading loads a program’s parts into memory only when they are needed, rather than loading the entire program at once. This reduces the amount of RAM consumed by any specific program at any given moment and allows more simultaneous loading of programs.
Feature | Logical Address Space | Physical Address Space |
Definition | The address generated by the CPU during program execution. | The actual address in the memory unit. |
View | User view of the memory (virtual address). | Hardware view of the memory. |
Access | Managed by the OS using memory management techniques. | Directly accessed by the memory hardware. |
Overlays are mechanisms used to work around physical memory limitations within systems by loading only relevant instructions and data segments into memory. Whenever some different portion of this program may be needed, the current overlay is replaced with the required one. By using this technique, large-sized applications can run on low-memory systems without compromising their functionality at all.
Fragmentation occurs when memory is allocated and deallocated in a way that leaves small, unusable gaps. It comes in two types:
Type | Description |
Internal Fragmentation | Unused memory within allocated regions, due to the allocated size being larger than needed. |
External Fragmentation | Unused memory between allocated regions, due to varying sizes of memory allocation and deallocation. |
It is a memory management technique that divides a process’s memory into pages that have fixed sizes and physical memory into frames with similar sizes. The functionality of paging provides a way to connect virtual addresses to physical addresses, thereby making it possible for computer systems to use memory in an efficient manner without the need for contiguous allocation.
Swapping improves memory management by temporarily moving inactive processes from the main memory to a storage device (swap space). This frees up RAM for active processes, allowing the system to handle more processes concurrently and improve overall performance. When the swapped-out process is needed again, it is swapped back into memory.
The Direct Access Method allows data to be read or written directly to a specific location on a storage device without sequentially accessing preceding data. This method is commonly used in disk drives where each block or sector has a unique address, enabling quick access to data and improving performance for large data sets.
Generally, thrashing occurs when the computer system spends more of its time paging-that is swapping data in and out of memory rather than actually executing any processes. This can be due to a shortage of available RAM, given that heavy paging drastically reduces the performance of the system.
Interrupts mean signals that are sent to CPU by software or hardware, indicating an event which needs immediate attention. When an interrupt takes place, the CPU temporarily stops executing current instructions and transfers control to an interrupt handler to address the event. After handling the interrupt, the CPU resumes its normal execution.
Preemptive multitasking is one of the methods used to schedule a central processing unit. In this technique, the operating system allots CPU time for the processes and can forcefully remove a process from the CPU when it is actually allotting another process’s time. This technique guarantees an equal share of CPU time for all the processes and enhances the response of this system by disallowing one process to hold the CPU fully.
Advantage | Description |
Synchronisation | Semaphores help synchronise access to shared resources, preventing race conditions. |
Mutual Exclusion | Ensures that only one process accesses a critical section at a time. |
Simplicity | Provides a simple mechanism for managing concurrent processes. |
Flexibility | Can be used for both signalling and resource counting, making them versatile. |
Efficiency | Reduces the need for busy waiting, as processes can be blocked until the semaphore is available. |
Inter-process Communication (IPC) is a method through which several processes communicate with each other and, at the same time, synchronise their actions. Some of these are message passing, shared memory, semaphores, pipes, etc., that allow sharing of the data and thus synchronisation amongst all these diverse processes.
A Batch Operating System processes batches of jobs with similar requirements together, without user interaction during execution. Jobs are collected, grouped, and processed sequentially, improving resource utilisation and throughput.
Concept | Description |
Starvation | Occurs when a process waits indefinitely for resources due to continuous resource allocation to other processes. |
Aging | A technique used to prevent starvation by gradually increasing the priority of waiting processes over time. |
A Process Control Block (PCB) is a data structure used by the operating system to store information about a process. The PCB contains details such as:
Field | Description |
Process ID (PID) | Unique identifier for the process |
Process State | Current state of the process (e.g., running, waiting) |
Program Counter | Address of the next instruction to execute |
CPU Registers | Current values of the CPU registers |
Memory Management | Information about memory allocation |
A system is in a safe state if there exists a sequence of processes such that each process can be allocated the necessary resources and complete its execution without causing a deadlock. In a safe state, the system can avoid deadlock by careful resource allocation.
Cycle stealing entails Direct Memory Access (DMA) controllers transferring data between memory and I/O devices directly by ‘stealing’ CPU cycles. During cycle stealing, the DMA controller gains access to memory while momentarily halting the operation of the Central Processing Unit, thereby reducing its workloads in many cases related to data transfer operations.
Concept | Description |
Trap | A trap is a software-generated interrupt caused by an error or specific condition in a program, triggering a switch to the OS to handle the event. |
Trapdoor | A trapdoor (or backdoor) is a hidden method of bypassing normal authentication or security controls, often used maliciously to gain unauthorised access to a system. |
Dispatcher is a component of the CPU scheduler that transfers control over CPU selection made by the scheduler itself. The dispatcher performs context switching, i.e., changing the CPU from one process to another selected process and ensuring the selected process starts execution.
Locality of reference refers to the tendency of a program to access a relatively small set of memory locations repeatedly over a short period. It is divided into two types:
Type | Description |
Temporal Locality | Recently accessed memory locations are likely to be accessed again soon. |
Spatial Locality | Memory locations near recently accessed locations are likely to be accessed soon. |
Performance in virtual memory is calculated by evaluating the following factors:
Factor | Description |
Page Fault Rate | The frequency of page faults (lower is better) |
Effective Access Time (EAT) | Calculated as: EAT = (1 – Page Fault Rate) * Memory Access Time + Page Fault Rate * Page Fault Handling Time |
TLB Hit Rate | The frequency of successful lookups in the Translation Lookaside Buffer (TLB) (higher is better) |
Reentrancy refers to the ability of a program or function to be safely interrupted and called again (“re-entered”) before its previous executions are complete. Reentrant code does not rely on shared data and uses local variables, allowing multiple instances to execute concurrently without causing conflicts.
Kernel Type | Description |
Monolithic Kernel | A single large kernel that handles all OS services in one address space. |
Microkernel | A minimal kernel that runs basic services like communication and I/O in kernel space, with other services in user space. |
Hybrid Kernel | Combines features of monolithic and microkernels to improve performance and modularity. |
Exokernel | Provides minimal abstractions and allows applications to manage hardware resources directly. |
Nanokernel | An extremely lightweight kernel that performs very few basic tasks, mainly used in embedded systems. |
Semaphore is a synchronisation variable that controls the number of processes that can access some common resource in a concurrent system. Basically, it’s an integer variable that could be increased or decreased due to the request of a process. Semaphores are majorly used to combat the problems of critical section and race conditions, as they ensure proper and secure access of shared resources.
Function | Description |
Process Management | Manages process creation, scheduling, and termination. |
Memory Management | Controls memory allocation and deallocation. |
Device Management | Manages communication between hardware devices and the system. |
File System Management | Handles file creation, deletion, and access control. |
Security and Access Control | Enforces security policies and controls access to system resources. |
System Calls Management | Provides an interface for user applications to interact with the hardware. |
Feature | Microkernel | Monolithic Kernel |
Structure | Minimal core functions in kernel space, other services in user space. | All OS services run in kernel space. |
Size | Smaller | Larger |
Performance | It can be slower due to user-space communication overhead. | Generally faster due to direct service handling in kernel space. |
Reliability | More reliable and secure due to isolated services. | Less reliable as a bug in one service can crash the entire system. |
Extensibility | Easier to extend and modify without affecting the entire system. | Harder to modify and extend due to tightly coupled services. |
Symmetric multiprocessing (SMP) can be defined as an architecture in which one common memory exists with multiple processors operating under one operating system instance. For each processor, it has equal access towards memory as well as I/O devices such that multitasking applications have parallel processing, resulting in better performance.
Time-sharing allows several users or tasks to share the same system resources at once by switching between them quickly. Each user or task is given a short amount of time for their execution which gives the impression of having many processes running at the same time thus increasing the general performance and responsiveness of the systems.
Aspect | Benefits | Disadvantages |
Efficiency | Maximises resource utilisation by executing batches of jobs. | Lack of interaction and flexibility for real-time tasks. |
Automation | Reduces manual intervention and automates repetitive tasks. | Difficult to debug and handle errors during job execution. |
Throughput | High throughput due to streamlined job processing. | Long turnaround time for individual jobs. |
Cost | Lower operational costs due to efficient resource usage. | Inflexibility in handling diverse job requirements. |
A bootstrap program is the very first code that gets executed after a computer is started or reset. It has to initialise the hardware and do any other preparation necessary to make the environment run an operating system, which then also reads the OS kernel from disk into memory. A bootstrap program resides in the computer’s firmware (e.g., BIOS or UEFI)computer’s, which may be implemented in various ways depending on the computer design.
IPC Mechanism | Description |
Pipes | Allows communication between processes through a unidirectional data stream. |
Message Queues | Enables processes to exchange messages in a queue. |
Shared Memory | Allows multiple processes to access a common memory space. |
Semaphores | Synchronises access to shared resources using signalling mechanisms. |
Sockets | Facilitates communication between processes over a network. |
Signals | Uses asynchronous notifications to communicate events to processes. |
Deadlock takes place when there exist some processes that cannot go forward because every process waits for another process among this set holding a resource they need. Consequently, no single process can complete its execution, leading to the halting of the entire system. Deadlocks mainly involve four conditions: mutual exclusion, hold and wait, no preemption, and circular wait.
Belady’s Anomaly is a phenomenon in some page replacement algorithms where increasing the number of page frames results in an increase in the number of page faults. It occurs in algorithms like FIFO (First-In, First-Out), where more memory can paradoxically lead to worse performance due to suboptimal page replacement decisions.
Spooling (simultaneous peripheral operations online) is a technique where data is held temporarily in a buffer so that it can be used and executed by another device or program later on. This method is often employed for print management purposes whereby documents are spooled to disk or memory and lined up for printing, freeing up CPU cycles so that it can perform other tasks.
Batch Operating Systems are used in environments where large volumes of similar jobs are processed without user interaction. Real-life applications include:
Monitors are high-level synchronisation constructs used to control access to shared resources in concurrent programming. They combine mutual exclusion (mutex) and condition variables to manage the safe execution of code blocks by allowing only one process or thread to execute within the monitor at a time.
A zombie process is a process that has completed execution but still has an entry in the process table. This occurs when the process’s parent has not read its exit status using the wait() system call. Zombie processes occupy a slot in the process table but do not consume system resources.
Understanding concepts in an operating system will definitely raise the bar during technical interviews, providing you with a leading edge in the field of software development and IT. In this tutorial, you have learned process management, memory management, file systems, and security, all very important concepts that form the basis for undertaking questions related to operating systems. This helps a lot in enhancing problem-solving skills and showcasing technical strengths to prospective hiring companies.
The following questions are practice sets for you. Afterwards, apply these to real situations and continue to study for your interview. Thorough preparation and a solid operating systems knowledge base will give you the confidence to handle tough interview questions and further your career in technology.
The DevOps Playbook
Simplify deployment with Docker containers.
Streamline development with modern practices.
Enhance efficiency with automated workflows.
Popular
Data Science
Technology
Finance
Management
Future Tech
Accelerator Program in Business Analytics & Data Science
Integrated Program in Data Science, AI and ML
Certificate Program in Full Stack Development with Specialization for Web and Mobile
Certificate Program in DevOps and Cloud Engineering
Certificate Program in Application Development
Certificate Program in Cybersecurity Essentials & Risk Assessment
Integrated Program in Finance and Financial Technologies
Certificate Program in Financial Analysis, Valuation and Risk Management
© 2024 Hero Vired. All rights reserved