Lab viva guide

Operating system viva questions and answers: 74 short spoken answers for the OS lab, grouped by topic

26 min read Updated English

Operating system viva questions follow the OS lab programs: you run the scheduling, Banker's algorithm or page replacement program from the list, and the examiner asks you to explain it, work out a waiting time, and then answers the question every OS viva reaches, deadlock. This page gives 74 OS viva questions with short spoken answers, grouped from basics to processes, scheduling, synchronisation, deadlock, memory, files and Linux, so you can jump to the topic of your experiment and say the answers out loud.

How the examiner runs an OS lab viva

Most university OS labs are a set of C programs that simulate what the kernel does: FCFS, SJF, priority and round robin scheduling, the producer-consumer problem with semaphores, Banker's algorithm, page replacement, memory allocation and disk scheduling, plus Linux commands, shell scripts and the fork and exec system calls. At the practical you execute one program and then face a five-to-ten-minute viva with your record open. Viva marks are a separate part of the practical marks under most schemes.

  • First, your program: 'explain your round robin output' or 'why did you choose quantum 2?'
  • Then a calculation: average waiting time for three processes, or page faults for a short reference string with three frames.
  • Then a definition from the same unit: semaphore, safe state, page fault, thrashing.
  • Then a comparison: process versus thread, paging versus segmentation, mutex versus semaphore.
  • Deadlock and its four conditions come up in almost every OS viva, whatever your experiment.

Bring a pen to the viva

Scheduling and page replacement answers are easier to say when you draw the Gantt chart or the frame table as you talk. Examiners like a student who works it out on paper and explains each step aloud.

OS basics, kernel and system calls

What is an operating system?

An operating system is system software that manages the computer's hardware and provides services to programs. It acts as an interface between the user and the hardware and handles process, memory, file and device management, along with security. Examples are Linux, Windows, macOS and Android.

What are the main functions of an operating system?

Process management, which covers creation, scheduling and synchronisation; memory management; file system management; device and I/O management through drivers; security and access control; and providing a user interface, either a shell or a GUI. It also handles errors and accounts for resource use.

What is a kernel?

The kernel is the core of the operating system that stays in memory and runs in privileged mode. It manages the CPU, memory, devices and system calls. Everything else, such as the shell, utilities and applications, runs in user mode and asks the kernel for services.

What is the difference between a monolithic kernel and a microkernel?

In a monolithic kernel, all services such as file systems, drivers and memory management run together in kernel space, which is fast; Linux is the common example. A microkernel keeps only the essentials, like scheduling and IPC, in the kernel and runs other services in user space, which is more reliable but adds message-passing overhead.

What is a system call? Give examples.

A system call is the interface through which a user program asks the kernel for a service, switching from user mode to kernel mode. Examples in Linux are fork, exec, wait, exit, open, read, write, close and kill. printf itself is a library function that eventually calls write.

What is the difference between user mode and kernel mode?

In user mode a program can run only non-privileged instructions and cannot touch hardware or other programs' memory directly. In kernel mode the CPU can execute every instruction. A mode bit in the processor records the current mode, and system calls and interrupts switch it to kernel mode.

What are the types of operating systems?

Batch systems run jobs in groups without interaction; multiprogramming keeps several jobs in memory to keep the CPU busy; time-sharing or multitasking switches quickly so users can interact; multiprocessor systems use several CPUs; distributed systems link computers over a network; and real-time systems guarantee responses within deadlines.

What is a real-time operating system? What are hard and soft real-time?

A real-time OS must respond within fixed time limits. In a hard real-time system, missing a deadline is a failure, as in airbag control or pacemakers. In a soft real-time system, an occasional miss lowers quality but is tolerated, as in video streaming.

What is multiprogramming versus multitasking?

Multiprogramming keeps several programs in memory so that when one waits for I/O, the CPU runs another; the aim is CPU utilisation. Multitasking, or time-sharing, extends this by giving each task a short time slice so users can interact with several programs at once; the aim is response time.

What is an interrupt?

An interrupt is a signal to the CPU that an event needs attention, such as a key press, a disk transfer finishing or a timer expiring. The CPU saves its state, runs the interrupt service routine and then resumes. A trap is a software-generated interrupt, caused by a system call or an error like divide by zero.

What happens when a computer boots?

The firmware, BIOS or UEFI, runs a power-on self-test and finds a boot device. It loads the bootloader, such as GRUB, which loads the kernel into memory. The kernel initialises hardware and memory, mounts the root file system and starts the first user process, init or systemd on Linux.

Processes, threads, fork and IPC

What is a process? How is it different from a program?

A program is a passive file of instructions on disk. A process is a program in execution, with its own program counter, registers, stack, heap, data section and open files. One program, such as a browser, can run as several processes at the same time.

What are the states of a process?

New, when it is being created; ready, waiting for the CPU; running, executing on the CPU; waiting or blocked, waiting for I/O or an event; and terminated. A running process moves to ready when its time slice ends and to waiting when it requests I/O.

What is a PCB?

The process control block is the data structure the OS keeps for each process. It holds the process ID, state, program counter, CPU registers, scheduling priority, memory-management information, the list of open files and accounting information. The OS saves and restores it during a context switch.

What is a context switch?

Switching the CPU from one process to another: the OS saves the current process's state in its PCB and loads the saved state of the next one. It is pure overhead, because no useful work is done during the switch, which is why a very small round robin quantum hurts performance.

What is the difference between a process and a thread?

A process has its own address space and resources. A thread is the smallest unit of execution inside a process; threads of the same process share code, data, heap and open files but each has its own stack, registers and program counter. Creating and switching threads is cheaper than processes.

What are user-level and kernel-level threads?

User-level threads are managed by a library in user space, so they are fast to create, but if one blocks on a system call the whole process may block. Kernel-level threads are managed by the OS, which can schedule them on different CPUs. Linux pthreads map each thread to a kernel thread.

What does fork return?

fork creates a child process that is a copy of the parent. It returns 0 in the child, the child's process ID in the parent, and minus 1 in the parent if creation fails. In my lab program I checked this value to print different messages from parent and child.

Common follow-up: how many processes do three fork calls in a row create? Eight in total, including the original.

What is the difference between fork and exec?

fork creates a new process that is a copy of the caller. exec replaces the current process's program with a new program, keeping the same process ID. A shell uses both: it forks a child, and the child calls exec to run the command you typed.

What is a zombie process?

A process that has finished but whose parent has not yet called wait to read its exit status, so its entry stays in the process table. It uses no CPU or memory beyond that entry. Calling wait or waitpid in the parent removes it.

What is an orphan process?

A process whose parent has terminated while it is still running. On Linux it is adopted by the init process, PID 1, or a designated subreaper, which later calls wait on it so it does not stay a zombie.

What is inter-process communication? Name the methods.

IPC lets processes exchange data and coordinate. The two models are shared memory and message passing. Common mechanisms are pipes and named pipes, message queues, shared memory segments, semaphores, signals and sockets. My lab used a pipe to send a string from parent to child.

What are the long-term, short-term and medium-term schedulers?

The long-term scheduler decides which jobs are admitted into memory and controls the degree of multiprogramming. The short-term or CPU scheduler picks which ready process runs next and runs very often. The medium-term scheduler swaps processes out of memory and back to manage load.

CPU scheduling algorithms

What are the scheduling criteria?

CPU utilisation and throughput should be maximised; turnaround time, waiting time and response time should be minimised. Turnaround time is completion time minus arrival time, and waiting time is turnaround time minus burst time. My programs printed both and their averages.

What is the difference between preemptive and non-preemptive scheduling?

In non-preemptive scheduling, a process keeps the CPU until it finishes or blocks, as in FCFS and plain SJF. In preemptive scheduling the OS can take the CPU away, for example when a time quantum expires or a higher-priority process arrives, as in round robin and SRTF.

How does FCFS work, and what is the convoy effect?

First come, first served runs processes in arrival order without preemption, using a simple queue. The convoy effect happens when a long process arrives first and all the short ones wait behind it, which raises the average waiting time sharply.

Why is SJF called optimal, and what is its drawback?

Shortest job first gives the minimum average waiting time for a given set of processes, because running short jobs first reduces the waiting of everyone behind them. Its drawbacks are that burst times are not known in advance and must be estimated, and long jobs can starve.

What is SRTF?

Shortest remaining time first is the preemptive version of SJF. When a new process arrives with a burst shorter than the remaining time of the running process, the running process is preempted. It gives even lower average waiting time but more context switches.

What is priority scheduling, and how do you prevent starvation?

Each process gets a priority and the CPU goes to the highest priority, preemptively or not. Low-priority processes may starve, waiting forever. The fix is aging: gradually raising the priority of processes that have waited a long time.

How does round robin work, and how does the time quantum affect it?

Each ready process gets the CPU for a fixed time quantum, then goes to the back of the ready queue. If the quantum is very large, round robin behaves like FCFS; if it is very small, too much time goes in context switches. It gives good response time for time-sharing.

Work out the average waiting time in FCFS for burst times 24, 3 and 3, all arriving at time 0.

In the order P1, P2, P3, the waiting times are 0, 24 and 27, so the average is 51 by 3, which is 17. If the short jobs run first, P2, P3, P1, the waiting times are 0, 3 and 6 and the average drops to 3, which shows the convoy effect.

Draw the Gantt chart first and read the waiting times off it.

What is multilevel queue and multilevel feedback queue scheduling?

A multilevel queue splits processes into fixed queues, such as system, interactive and batch, each with its own algorithm and priority. In a multilevel feedback queue, processes can move between queues: a CPU-heavy process sinks to a lower queue, and one that waits long can be moved up.

What is the difference between turnaround time and response time?

Turnaround time is the total time from arrival to completion. Response time is the time from arrival until the process first gets the CPU and starts responding. For interactive systems response time matters more, which is why round robin is used there.

Process synchronisation and semaphores

What is a race condition?

A race condition occurs when two or more processes or threads access shared data at the same time and the result depends on the order in which they run. Two threads each incrementing a shared counter a thousand times can end below two thousand without synchronisation.

What is a critical section, and what are the requirements of a solution?

The critical section is the part of code that accesses shared data. A correct solution must satisfy mutual exclusion, so only one process is inside at a time; progress, so a free section is not kept waiting; and bounded waiting, so no process waits forever.

What is a semaphore?

A semaphore is an integer variable accessed only through two atomic operations: wait, also called P, which decrements it and blocks if no resource is free, and signal, also called V, which increments it and wakes a waiting process. It was introduced by Edsger Dijkstra.

What is the difference between a binary and a counting semaphore?

A binary semaphore takes only 0 and 1 and is used for mutual exclusion. A counting semaphore can take any non-negative value and controls access to a resource with several instances, such as the number of empty slots in a buffer.

What is the difference between a mutex and a semaphore?

A mutex is a lock with ownership: the thread that locks it must unlock it, and it allows only one thread in. A semaphore is a signalling counter with no owner; any thread can signal it, and a counting semaphore can let several threads in.

Explain the producer-consumer problem and its semaphore solution.

A producer puts items into a fixed-size buffer and a consumer removes them; the producer must wait when the buffer is full and the consumer when it is empty. I used three semaphores: empty initialised to the buffer size, full initialised to 0, and mutex initialised to 1 for buffer access.

What is the readers-writers problem?

Many readers may read shared data at the same time, but a writer needs exclusive access. The first version gives readers priority, so writers can starve; the second gives writers priority, so readers can starve. It is solved with a mutex, a write semaphore and a reader count.

What is the dining philosophers problem?

Five philosophers sit around a table with one chopstick between each pair and need both neighbours' chopsticks to eat. If all pick up their left chopstick at once, they deadlock. Solutions include allowing at most four to sit, picking up both chopsticks only if both are free, or having one philosopher pick right first.

What is a monitor?

A monitor is a high-level synchronisation construct that bundles shared data with the procedures that use it and guarantees only one process is active inside at a time. Condition variables with wait and signal let processes wait inside it. Java's synchronized methods work on the same idea.

What is busy waiting, and what is a spinlock?

Busy waiting is when a process keeps looping to check a condition instead of blocking, which wastes CPU time. A spinlock is a lock that uses busy waiting. It is acceptable on multiprocessors when the lock is held very briefly, because it avoids the cost of a context switch.

Deadlock and Banker's algorithm

What is a deadlock?

A deadlock is a situation where a set of processes are each waiting for a resource held by another process in the same set, so none of them can proceed. For example, P1 holds the printer and waits for the scanner while P2 holds the scanner and waits for the printer.

What are the four necessary conditions for deadlock?

Mutual exclusion, where a resource can be held by only one process; hold and wait; no preemption, where resources cannot be forcibly taken; and circular wait. All four must hold at the same time for a deadlock to occur, so breaking any one prevents it.

These are often called the Coffman conditions; name them in this order without pausing.

What is the difference between deadlock prevention and avoidance?

Prevention designs the system so one of the four conditions can never hold, for example by ordering resources to stop circular wait. Avoidance allows all conditions but checks each request at run time and grants it only if the system stays in a safe state, as Banker's algorithm does.

What is a safe state?

A state is safe if there is at least one order, called a safe sequence, in which every process can get its maximum need and finish. An unsafe state does not mean deadlock has occurred, only that it may occur if processes request their maximum.

How does Banker's algorithm work?

For each process it keeps Allocation, Max and Need, where Need equals Max minus Allocation, and an Available vector. The safety algorithm repeatedly finds a process whose Need fits in Available, assumes it finishes and adds its Allocation back. If all processes can finish, the state is safe and the request is granted.

What is a resource allocation graph?

A directed graph with process nodes and resource nodes; a request edge goes from a process to a resource and an assignment edge from a resource to a process. With single-instance resources, a cycle means deadlock; with multiple instances, a cycle means deadlock is possible but not certain.

How does an OS recover from deadlock?

After detection, it can terminate all deadlocked processes or kill them one at a time until the cycle breaks, or preempt resources from a victim process and roll it back. Most general-purpose systems, including Linux and Windows, largely ignore deadlock and leave it to applications, called the ostrich approach.

What is the difference between deadlock and starvation?

In deadlock, processes wait for each other in a cycle and none can ever proceed. In starvation, a process waits indefinitely because others keep getting preference, though the system as a whole keeps working. Aging fixes starvation; it does not fix deadlock.

Memory management, paging and virtual memory

What is the difference between logical and physical address?

A logical or virtual address is generated by the CPU for a program; a physical address is the actual location in RAM. The memory management unit, the MMU, translates logical to physical addresses at run time, so each program can behave as if it starts at address zero.

What are first fit, best fit and worst fit?

They are strategies for placing a process in a free memory hole. First fit takes the first hole big enough; best fit takes the smallest hole that fits; worst fit takes the largest hole. First fit is usually fastest, and first and best fit both use memory better than worst fit.

What is the difference between internal and external fragmentation?

Internal fragmentation is wasted space inside an allocated block, such as the unused part of a fixed partition or the last page of a process. External fragmentation is when total free memory is enough but it is split into non-contiguous holes. Paging removes external fragmentation; compaction reduces it.

What is paging?

Paging divides physical memory into fixed-size frames and a process's logical memory into pages of the same size, so a process can be placed in non-contiguous frames. A page table maps each page number to a frame number. A logical address is split into a page number and an offset.

What is a TLB?

The translation lookaside buffer is a small, fast cache in the MMU that holds recent page-to-frame mappings. On a TLB hit the frame number is found without reading the page table in memory; on a miss the page table is read and the TLB updated. It makes paging fast in practice.

What is segmentation, and how is it different from paging?

Segmentation divides a program into variable-sized logical units such as code, stack and data, each with a base and limit in a segment table. Paging uses fixed-size blocks invisible to the programmer. Segmentation matches the program's structure but suffers external fragmentation; paging avoids it.

What is virtual memory?

Virtual memory lets a process run even if only part of it is in RAM, with the rest on disk. It gives each process a large address space, allows more programs in memory at once and is usually implemented by demand paging.

What is demand paging and a page fault?

In demand paging a page is loaded into memory only when it is first accessed. If the page is not in memory, the hardware raises a page fault; the OS finds the page on disk, loads it into a free frame or a victim frame, updates the page table and restarts the instruction.

Explain FIFO, LRU and optimal page replacement.

FIFO replaces the page that came into memory earliest. LRU replaces the page not used for the longest time. Optimal replaces the page that will not be used for the longest time in the future; it gives the fewest faults but cannot be implemented, so it is used as a benchmark.

What is Belady's anomaly?

With FIFO page replacement, increasing the number of frames can sometimes increase the number of page faults. The reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 gives 9 faults with three frames and 10 with four. LRU and optimal do not suffer from it.

Know this reference string by heart; it is the standard example.

What is thrashing?

Thrashing is when a process does not have enough frames, so it page-faults constantly and the system spends more time swapping pages than executing. CPU utilisation drops sharply. It is controlled with the working-set model, page-fault frequency control or by reducing the number of processes.

What is swapping?

Swapping moves a whole process, or in modern systems some of its pages, from main memory to a swap area on disk to free memory, and brings it back later. It lets the system run more processes than fit in RAM at once, at the cost of disk I/O time.

What is the difference between a page and a frame?

A page is a fixed-size block of a process's logical memory; a frame is a block of the same size in physical memory. The page table records which frame holds each page. Page sizes are powers of two, commonly 4 KB, so the address splits cleanly into page number and offset.

Files, disk scheduling and Linux commands

What are the file allocation methods?

Contiguous allocation stores a file in consecutive blocks, which is fast but causes external fragmentation. Linked allocation chains blocks with pointers, so there is no fragmentation but random access is slow. Indexed allocation keeps all block addresses in an index block, which supports direct access.

What is an inode?

In Unix and Linux file systems, an inode stores a file's metadata: its size, owner, permissions, timestamps, link count and the addresses of its data blocks. It does not store the file name; the directory maps names to inode numbers.

What are the directory structures?

Single-level, where all files share one directory; two-level, with a separate directory per user; tree-structured, with subdirectories and paths, which most systems use; and acyclic-graph, which allows shared files through links. Linux uses a tree starting at the root directory.

What are the disk scheduling algorithms?

FCFS serves requests in order; SSTF serves the request nearest the head; SCAN, the elevator algorithm, moves end to end serving requests; C-SCAN serves in one direction and jumps back; LOOK and C-LOOK turn at the last request instead of the disk end. SSTF can starve far requests.

What are seek time and rotational latency?

Seek time is the time for the disk arm to move the head to the right track. Rotational latency is the time for the required sector to rotate under the head. Disk scheduling algorithms mainly try to reduce total head movement, which reduces seek time.

What does chmod 755 mean?

Each digit is the sum of read 4, write 2 and execute 1, for owner, group and others in that order. So 755 gives the owner read, write and execute, and gives the group and others read and execute only. I used it to make my shell script executable.

Which Linux commands did you use in the lab?

ls, cd, pwd, mkdir, cp, mv and rm for files; cat, grep, head and tail for text; ps and top to see processes; kill to send a signal to a process; chmod for permissions; and man to read a command's manual. I also wrote shell scripts with if, for and while loops.

What is a shell?

A shell is a command interpreter that reads commands from the user or a script and asks the kernel to run them, using fork and exec. Bash is the common shell on Linux. A shell script is a text file of shell commands that runs as a program.

What is a pipe in Linux?

A pipe connects the standard output of one command to the standard input of the next, written with a vertical bar. For example, ps aux, pipe, grep python lists only the Python processes. Inside the kernel it is a one-way buffer between two processes.

What is RAID?

RAID, a redundant array of independent disks, combines several disks for speed, reliability or both. RAID 0 stripes data with no redundancy; RAID 1 mirrors data on two disks; RAID 5 stripes data with distributed parity, so it survives one disk failure.

Common mistakes in an OS viva

  • Listing the deadlock conditions but forgetting that all four must hold together, so breaking one is enough.
  • Saying an unsafe state is a deadlock. It only means deadlock is possible.
  • Mixing up the formulas: turnaround is completion minus arrival; waiting is turnaround minus burst.
  • Calling SJF optimal without the condition: it minimises average waiting time for a known set of jobs, and burst times must be estimated.
  • Saying a thread has its own memory. Threads share the process's code, data and heap; only the stack and registers are separate.
  • Saying fork returns the child's PID to the child. The child gets 0.
  • Claiming LRU suffers from Belady's anomaly. Only FIFO-type algorithms do.
  • Reading the program from the record instead of explaining it. The examiner wants the logic, not the lines.

What the ExamPilot AI examiner checks when you practise

In a CS/IT lab viva session on ExamPilot you tell the AI examiner which OS experiment you did, say round robin scheduling or Banker's algorithm, and it questions you by voice for about ten minutes. It asks you to explain your output, makes you work out a waiting time or a page-fault count aloud, then moves to definitions and comparisons, and always reaches deadlock. You can answer in English or Hindi.

  • Correct terms: safe state, page fault, critical section, context switch, used precisely.
  • Step-by-step working: whether you say each step of a Gantt chart or frame table instead of jumping to a number.
  • Comparisons with a reason, not just a list: why a mutex differs from a semaphore, not only that it does.
  • Brevity: two or three sentences, then a stop.
  • Honesty: a clean 'I am not sure' instead of a guess.
  • Fluency and pace, since a clear explanation is part of the viva mark.

Start with the CS/IT lab viva mock. You get a transcript with the questions you fumbled and a shorter version of each answer to say again.

The night before the OS lab exam

  1. 1

    Run every program once

    Change the input, such as the time quantum or the number of frames, and check that you can predict the new output before you run it.

  2. 2

    Solve two numericals by hand

    One round robin schedule with waiting and turnaround times, and one page replacement string with FIFO and LRU. Say each step aloud.

  3. 3

    Say the eight definitions without looking

    Process, thread, PCB, context switch, semaphore, deadlock, safe state, page fault. Then the four deadlock conditions in one breath.

  4. 4

    Run one mock viva

    Ten minutes with the AI examiner on your experiment shows which answers come out cleanly and which you only recognise on paper.

Most OS labs are written in C, so revise C programming viva questions for questions on your code. The systems semester also brings computer network viva questions and DBMS viva questions. For how every lab viva works, read the engineering viva questions hub.

Frequently asked questions

What are the most important operating system viva questions?
Process versus thread, process states and the PCB, the scheduling algorithms with one numerical, semaphores and the producer-consumer problem, the four deadlock conditions and Banker's algorithm, paging and virtual memory, page replacement with Belady's anomaly, and thrashing. In the lab viva, expect questions on the exact program you executed first, so revise that program's logic and output.
Do examiners ask numericals in an OS viva?
Often. A short scheduling problem with three processes, or a page replacement string with three frames, takes two minutes and shows whether you understand the algorithm. Draw the Gantt chart or frame table, say each step aloud and give the average at the end with the formula you used. Getting the method right matters more than speed.
Which OS topics come up in placement interviews?
Process versus thread, deadlock and its conditions, mutex versus semaphore, paging and virtual memory, thrashing and context switching are the usual ones in fresher technical rounds. Interviewers expect the same short definitions as a viva plus a real example, such as how a browser uses several processes. The answers on this page work for both.
How long should an OS viva answer be?
Two or three sentences for a definition, about twenty to thirty seconds. For a comparison, give one line for each side and the one key difference. For a numerical, talk through the working. If the examiner wants more, they ask a follow-up, and handling that follow-up well is where full viva marks come from.
How can I practise OS viva questions out loud?
Knowing an answer when you read it is not the same as saying it under questioning. On ExamPilot you can run a CS/IT lab viva by voice: name your OS experiment, and the AI examiner asks about your program, makes you work out a numerical aloud and follows up the way an external examiner does, then gives you a transcript to review. It is free to start, in English or Hindi.

Practise out loud

Practise your OS lab viva out loud

The AI examiner asks about your scheduling, deadlock or paging program, makes you work a numerical aloud and scores correctness, clarity and brevity.

Engineering Viva · CS / IT lab viva

Read how this interview works

Official sources