SLST OS Full Study Notes
1. Concept of Operating System
• Definition:
An Operating System is a system program that acts as an intermediary between the user and computer hardware.
It manages hardware resources, provides an environment for application execution, and offers convenience to the user.
• Basic Role:
1. Resource Manager – Manages CPU, memory, I/O, and files.
2. Control Program – Prevents errors and improper use of the computer.
3. Coordinator – Manages execution of user programs.
• Structure of a Computer System:
1. Hardware (CPU, memory, I/O devices)
2. OS
3. System Programs (Compilers, Editors)
4. Application Programs
5. Users
• Goals:
o Convenience – Easier interaction between human and machine.
o Efficiency – Optimal use of hardware resources.
o Ability to evolve – Support new hardware/software.
2. Functions of OS
Primary Functions
1. Process Management
o Creating and deleting processes.
o Scheduling processes.
o Synchronization and communication between processes.
o Deadlock handling.
2. Memory Management
o Keeping track of which memory parts are in use.
o Allocating/deallocating memory space.
o Managing virtual memory.
3. File System Management
o Creating, deleting, reading, writing, and organizing files.
o Managing file permissions.
4. I/O System Management
o Buffering, caching, spooling.
o Managing device drivers.
5. Security and Protection
o User authentication, password protection, file access rights.
6. Command Interpretation
o User interface: CLI (Command Line Interface), GUI (Graphical User Interface).
3. Classification of OS
By Processing Mode:
• Batch Processing OS – Executes jobs in batches without user interaction.
• Multiprogramming OS – Several jobs loaded in memory; CPU switches among them.
• Time Sharing OS – Each job gets CPU for a short period (time quantum).
• Real-Time OS – Immediate processing, strict deadlines.
o Hard real-time: Missed deadlines = system failure.
o Soft real-time: Delays acceptable but undesirable.
• Distributed OS – Controls multiple computers and makes them appear as one.
• Network OS – Provides networking support for file sharing and communication.
• Mobile OS – Designed for smartphones and tablets.
By User:
• Single-user OS – One user at a time (e.g., MS-DOS).
• Multi-user OS – Multiple users at the same time (e.g., Unix).
By Task:
• Single-tasking – One program runs at a time.
• Multi-tasking – Multiple programs run seemingly at the same time.
4. Process Scheduling
• Process: Program in execution.
• States:
o New → Ready → Running → Waiting → Terminated.
• Scheduler Types:
1. Long-term scheduler – Controls number of processes in memory.
2. Medium-term scheduler – Suspends/resumes processes.
3. Short-term scheduler – Chooses next process for CPU.
Scheduling Algorithms:
1. FCFS (First Come First Serve)
o Non-preemptive, processes executed in arrival order.
o Problem: Convoy effect – long job delays shorter jobs.
2. SJF (Shortest Job First)
o Minimum burst time first.
o Optimal for average waiting time but needs burst time in advance.
3. Priority Scheduling
o High priority runs first.
o Can cause starvation → solved by aging.
4. Round Robin (RR)
o Time slice (quantum) given to each process in turn.
o Good for time-sharing systems.
5. Multilevel Queue Scheduling
o Different queues for different process types (foreground, background).
6. Multilevel Feedback Queue
o Processes can move between queues based on behavior.
5. Memory Management
• Main Goals:
o Keep track of each memory location.
o Allocate memory when needed.
o Reclaim memory when not needed.
Memory Allocation Methods:
1. Contiguous Allocation
o Fixed or variable-sized partitions.
o Problem: Fragmentation (internal & external).
2. Non-contiguous Allocation:
o Paging:
▪ Physical memory divided into fixed-size frames.
▪ Logical memory divided into pages.
▪ Page Table maps pages to frames.
o Segmentation:
▪ Memory divided into variable-sized segments (code, data, stack).
▪ Segment Table used.
3. Virtual Memory:
o Allows execution of processes not completely in memory.
o Implemented via demand paging.
4. Page Replacement Algorithms:
o FIFO – Replace oldest page.
o LRU – Replace least recently used page.
o Optimal – Replace page not needed for the longest future time.
6. Deadlock
• Definition:
Condition where processes are permanently blocked, waiting for resources held by each other.
• Necessary Conditions (Coffman’s):
1. Mutual Exclusion – Only one process uses a resource at a time.
2. Hold and Wait – Process holds at least one resource and requests more.
3. No Preemption – Resources cannot be forcibly taken.
4. Circular Wait – Circular chain of processes waiting for resources.
• Deadlock Handling Methods:
1. Prevention – Deny at least one of the four conditions.
2. Avoidance – Use safe states (e.g., Banker’s Algorithm).
3. Detection & Recovery – Detect deadlock and take action (kill process or preempt resources).
4. Ignore – Assume deadlock will not happen (Ostrich algorithm).
Topic 1 – Concept of Operating System (50 MCQs)
1. Which of the following best defines an operating system?
a) A collection of hardware components
b) A set of programs that manages computer hardware resources
c) A compiler for programming languages
d) An application software for word processing
Answer: b
Explanation: An OS is system software that manages hardware resources and provides services to applications.
2. The OS acts as a ______ between user and hardware.
a) Barrier
b) Interface
c) Program
d) File
Answer: b
Explanation: The OS provides an interface so users can interact with hardware indirectly.
3. Which one is NOT a goal of an OS?
a) Convenience
b) Efficiency
c) Evolution
d) Hardware manufacturing
Answer: d
Explanation: OS is software; manufacturing hardware is not its function.
4. Which of these is NOT system software?
a) Operating System
b) Compiler
c) MS Paint
d) Device Driver
Answer: c
Explanation: MS Paint is an application, not system software.
5. The main component of an OS that manages processes is called:
a) Shell
b) Kernel
c) Cache
d) File Manager
Answer: b
Explanation: The kernel is the core part of the OS managing processes, memory, and devices.
6. Which is NOT an example of an OS?
a) Linux
b) Windows 10
c) Android
d) Oracle
Answer: d
Explanation: Oracle is a database management system.
7. Who interacts directly with hardware?
a) User
b) Application programs
c) Operating System
d) Device drivers only
Answer: c
Explanation: OS communicates with hardware through kernel and device drivers.
8. In computer systems, the OS is loaded into memory by a:
a) Compiler
b) Loader
c) Bootloader
d) Assembler
Answer: c
Explanation: Bootloader loads OS from disk into memory at startup.
9. Which layer sits directly above the hardware?
a) Application programs
b) System software
c) Kernel
d) GUI
Answer: c
Explanation: Kernel directly interacts with hardware.
10. A program in execution is called:
a) Job
b) Process
c) Task
d) Instruction
Answer: b
Explanation: OS refers to a running program as a process.
11. Which OS component schedules CPU time?
a) Memory Manager
b) Scheduler
c) File System
d) Device Driver
Answer: b
Explanation: The scheduler allocates CPU to processes.
12. Which is NOT an example of a multitasking OS?
a) Windows
b) Linux
c) DOS
d) macOS
Answer: c
Explanation: DOS is single-tasking.
13. The first operating system for microcomputers was:
a) MS-DOS
b) CP/M
c) UNIX
d) Windows 1.0
Answer: b
Explanation: CP/M (Control Program for Microcomputers) was among the earliest.
14. UNIX was developed in:
a) Microsoft
b) Bell Labs
c) IBM
d) Intel
Answer: b
Explanation: Ken Thompson & Dennis Ritchie at Bell Labs developed UNIX.
15. Which is NOT a real-time OS?
a) VxWorks
b) RTLinux
c) Windows XP
d) QNX
Answer: c
Explanation: Windows XP is general-purpose.
16. Time-sharing systems aim to:
a) Run one job at a time
b) Minimize response time
c) Eliminate multiprogramming
d) Reduce throughput
Answer: b
Explanation: Time-sharing systems give quick responses to multiple users.
17. Which OS generation introduced multiprogramming?
a) First generation
b) Second generation
c) Third generation
d) Fourth generation
Answer: c
Explanation: Third generation computers used multiprogramming and spooling.
18. An OS that can run on different hardware platforms is:
a) Embedded OS
b) Portable OS
c) Network OS
d) Batch OS
Answer: b
Explanation: Portable OS is adaptable to various hardware.
19. The heart of the OS is the:
a) Shell
b) Kernel
c) File system
d) Command interpreter
Answer: b
Explanation: Kernel is core to OS operations.
20. Which of these is an example of a single-user, single-tasking OS?
a) MS-DOS
b) Linux
c) Windows
d) Android
Answer: a
Explanation: MS-DOS executes one process at a time.
21. Which of these is the user interface for an OS?
a) Kernel
b) Shell
c) Cache
d) BIOS
Answer: b
Explanation: The shell acts as the command interpreter between user and kernel.
22. Which type of OS allows many users to share the computer simultaneously?
a) Single-user
b) Multi-user
c) Embedded
d) Real-time
Answer: b
Explanation: Multi-user OS supports concurrent access for multiple users.
23. Which is NOT an embedded OS?
a) Symbian
b) Windows CE
c) DOS
d) Palm OS
Answer: c
Explanation: DOS is not designed for embedded systems.
24. Which OS is open-source?
a) Windows
b) Linux
c) macOS
d) iOS
Answer: b
Explanation: Linux source code is publicly available.
25. The OS loads device drivers during:
a) Shutdown
b) Booting
c) Compilation
d) Linking
Answer: b
Explanation: Drivers are loaded at system startup.
26. Which of the following is an example of a batch processing system?
a) Payroll system
b) ATM system
c) Railway reservation system
d) Video conferencing
Answer: a
Explanation: Payroll is processed in batches without user interaction.
27. The BIOS is stored in:
a) Hard disk
b) ROM
c) RAM
d) Cache
Answer: b
Explanation: BIOS is firmware stored in ROM.
28. Which OS is mainly used for supercomputers?
a) Windows 7
b) UNIX/Linux variants
c) DOS
d) Chrome OS
Answer: b
Explanation: Linux/UNIX dominate in high-performance computing.
29. Which OS function controls hardware devices?
a) File management
b) Device management
c) Process scheduling
d) Networking
Answer: b
Explanation: Device management uses drivers to control hardware.
30. Which OS is designed to work on mobile devices?
a) Android
b) Windows Server
c) Red Hat Enterprise Linux
d) MS-DOS
Answer: a
Explanation: Android is a mobile OS based on Linux.
31. In which generation did GUI-based OS become common?
a) First
b) Second
c) Third
d) Fourth
Answer: d
Explanation: Fourth generation saw personal computers with GUIs.
32. Which OS component manages secondary storage?
a) Memory manager
b) File system
c) Scheduler
d) Kernel only
Answer: b
Explanation: The file system organizes and manages data on disks.
33. Which OS was developed first: Windows or UNIX?
a) Windows
b) UNIX
Answer: b
Explanation: UNIX (1970s) came before Windows (1980s).
34. Which is NOT a characteristic of an OS?
a) Resource allocation
b) User convenience
c) Batch processing
d) Compiling source code
Answer: d
Explanation: Compiling is done by a compiler, not the OS.
35. Which OS runs on IBM mainframes?
a) z/OS
b) Android
c) DOS
d) Windows 11
Answer: a
Explanation: IBM mainframes use z/OS.
36. The OS manages which types of resources?
a) CPU
b) Memory
c) I/O devices
d) All of the above
Answer: d
Explanation: OS manages all hardware resources.
37. Which OS is most widely used in servers?
a) Linux
b) Windows 98
c) DOS
d) Symbian
Answer: a
Explanation: Linux dominates server OS usage.
38. A __________ is a program that provides the OS with device-specific control.
a) Kernel
b) Device driver
c) API
d) Shell
Answer: b
Explanation: Drivers enable communication between OS and hardware.
39. The term “booting” means:
a) Restarting the OS
b) Loading the OS into memory
c) Shutting down the computer
d) Installing software
Answer: b
Explanation: Booting loads the OS into RAM.
40. Which OS was the first to support GUI?
a) Windows 95
b) macOS
c) Xerox Alto
d) Linux
Answer: c
Explanation: Xerox Alto (1970s) pioneered GUI.
41. Which OS is NOT based on UNIX?
a) macOS
b) Linux
c) Windows
d) Android
Answer: c
Explanation: Windows is not UNIX-based.
42. Which OS feature ensures that no process can access unauthorized memory?
a) Protection
b) Multiprogramming
c) Time-sharing
d) Spooling
Answer: a
Explanation: Memory protection prevents illegal access.
43. Which OS feature ensures that multiple processes can run at the same time?
a) Multitasking
b) Monoprogramming
c) Memory protection
d) BIOS
Answer: a
Explanation: Multitasking allows concurrent execution.
44. In a layered OS design, which is at the lowest layer?
a) Applications
b) Kernel
c) Hardware
d) File system
Answer: c
Explanation: Hardware is at the base.
45. Which OS supports distributed computing?
a) DOS
b) UNIX/Linux
c) Windows 3.1
d) CP/M
Answer: b
Explanation: Linux/UNIX can support distributed systems.
46. Which OS is designed for minimal power consumption?
a) Embedded OS
b) Multi-user OS
c) Batch OS
d) Network OS
Answer: a
Explanation: Embedded OS is optimized for low power.
47. Which OS was developed by Microsoft for servers?
a) Windows Server
b) Windows XP
c) Windows 95
d) Windows CE
Answer: a
Explanation: Windows Server is specialized for network/server use.
48. Which OS has a “Live CD” feature?
a) Windows 7
b) Linux
c) DOS
d) macOS
Answer: b
Explanation: Linux distros can run directly from CD/USB.
49. The OS that runs without installation on the system is called:
a) Embedded OS
b) Live OS
c) Batch OS
d) Multi-user OS
Answer: b
Explanation: Live OS boots from external media.
50. Which OS type is designed for controlling machinery in factories?
a) Real-time OS
b) Distributed OS
c) Network OS
d) Time-sharing OS
Answer: a
Explanation: Real-time OS ensures predictable timing for industrial control.
Part A – Spooling (20 MCQs)
Q1. In OS, "spooling" stands for:
a) Simultaneous Peripheral Operations On-Line
b) Serial Peripheral Output On-Line
c) Simultaneous Process Operations On-Line
d) Sequential Peripheral Operations On-Line
Answer: a
Q2. The primary purpose of spooling is:
a) Speed up CPU
b) Overlap I/O and computation
c) Reduce memory size
d) Increase context switching
Answer: b
Q3. Spooling uses which mechanism?
a) Stack
b) Queue
c) Paging
d) Semaphore
Answer: b
Q4. Spooling is mainly used in:
a) Disk scheduling
b) Printing
c) Paging
d) Deadlock avoidance
Answer: b
Q5. In printing, spooling allows:
a) Direct CPU control of printer
b) Multiple jobs to be queued
c) Printing without disk storage
d) Non-sequential job printing
Answer: b
Q6. Spooling reduces:
a) CPU usage
b) I/O idle time
c) Program size
d) Kernel size
Answer: b
Q7. Which scheduling policy is mostly used in spooling?
a) Round Robin
b) FIFO
c) SJF
d) Priority
Answer: b
Q8. In spooling, intermediate data is stored in:
a) Cache memory
b) Buffer
c) Virtual memory
d) ROM
Answer: b
Q9. The main advantage of spooling:
a) Device independence
b) More memory
c) Reduced CPU time
d) Lower disk usage
Answer: a
Q10. The spool area is usually in:
a) Primary memory
b) Hard disk
c) CPU registers
d) ROM
Answer: b
Q11. In Linux, printing spooling is handled by:
a) LPR
b) PRNT32
c) Spooler.exe
d) PrintSys
Answer: a
Q12. Spooling improves:
a) Memory usage
b) I/O throughput
c) Paging performance
d) Context switching speed
Answer: b
Q13. Spooling is beneficial when:
a) CPU is slower than I/O
b) CPU is faster than I/O
c) CPU and I/O same speed
d) None
Answer: b
Q14. Spooling is a type of:
a) Preprocessing
b) Buffering
c) Swapping
d) Virtualization
Answer: b
Q15. Spooling is mostly used in which type of systems?
a) Real-time
b) Batch processing
c) Time-sharing
d) Distributed
Answer: b
Q16. In spooling, CPU and I/O devices:
a) Work sequentially
b) Work in parallel
c) Work on same data
d) Block each other
Answer: b
Q17. Spooling queues jobs in:
a) Ready queue
b) Output queue
c) Wait queue
d) Input queue
Answer: b
Q18. Which device is least likely to use spooling?
a) Printer
b) Plotter
c) Monitor
d) Line printer
Answer: c
Q19. A disadvantage of spooling is:
a) Needs extra storage
b) Reduces throughput
c) Slows CPU
d) Prevents parallelism
Answer: a
Q20. Spooling is essential for:
a) CPU scheduling
b) Slow I/O devices
c) Large memory systems
d) Multiprocessor systems
Answer: b
Part B – Kernel (30 MCQs)
Q21. The kernel is part of:
a) Hardware
b) Operating system
c) Application software
d) Firmware
Answer: b
Q22. The kernel runs in:
a) User mode
b) Kernel mode
c) Supervisor mode only
d) Both kernel & user mode
Answer: b
Q23. Which of the following is NOT a kernel function?
a) Process management
b) Memory management
c) Device management
d) Text editing
Answer: d
Q24. Which kernel type loads all OS services in one memory space?
a) Microkernel
b) Monolithic kernel
c) Hybrid kernel
d) Nano kernel
Answer: b
Q25. Which kernel type runs minimal services in kernel space?
a) Microkernel
b) Monolithic kernel
c) Hybrid kernel
d) Exokernel
Answer: a
Q26. An example of a microkernel OS:
a) Linux
b) Windows NT
c) MINIX
d) MS-DOS
Answer: c
Q27. Linux kernel type is:
a) Microkernel
b) Monolithic with modular support
c) Hybrid kernel
d) Nano kernel
Answer: b
Q28. Kernel space is protected from:
a) User programs
b) Device drivers
c) Interrupts
d) System calls
Answer: a
Q29. The kernel acts as an interface between:
a) User and hardware
b) Application and compiler
c) CPU and ALU
d) RAM and ROM
Answer: a
Q30. Which is faster?
a) System calls
b) Kernel calls
c) User-level function calls
d) Same speed
Answer: c
Q31. Which scheduling is done by the kernel?
a) Long-term
b) Medium-term
c) Short-term
d) None
Answer: c
Q32. The kernel is loaded into memory by:
a) BIOS
b) Bootloader
c) Compiler
d) Application
Answer: b
Q33. Which kernel type is most stable?
a) Monolithic
b) Microkernel
c) Hybrid
d) Depends on design
Answer: d
Q34. The Linux kernel file is typically stored in:
a) /bin/kernel
b) /boot
c) /etc/kernel
d) /lib
Answer: b
Q35. Context switching is handled by:
a) CPU
b) Kernel
c) Compiler
d) BIOS
Answer: b
Q36. Which of these is NOT a kernel responsibility?
a) Process scheduling
b) Memory allocation
c) GUI rendering
d) Device control
Answer: c
Q37. The smallest possible kernel is called:
a) Microkernel
b) Nanokernel
c) Picokernel
d) Minikernel
Answer: b
Q38. Kernel communicates with hardware through:
a) API
b) System calls
c) Device drivers
d) Compilers
Answer: c
Q39. In microkernels, most services run in:
a) Kernel mode
b) User mode
c) Both modes
d) None
Answer: b
Q40. The term "hybrid kernel" means:
a) Combination of monolithic & microkernel features
b) Uses multiple CPUs
c) Uses cloud storage
d) Two kernels in one OS
Answer: a
Q41. The Windows NT kernel type is:
a) Monolithic
b) Microkernel
c) Hybrid kernel
d) Nanokernel
Answer: c
Q42. Which kernel is smallest in size?
a) Microkernel
b) Monolithic
c) Hybrid
d) Modular monolithic
Answer: a
Q43. Which part of the kernel handles file systems?
a) VFS (Virtual File System)
b) File Driver Manager
c) FAT handler
d) File Allocator
Answer: a
Q44. Interrupt handling is performed in:
a) User space
b) Kernel space
c) Both spaces
d) None
Answer: b
Q45. Which is a drawback of a monolithic kernel?
a) Large size
b) Complex debugging
c) Less modular
d) All of the above
Answer: d
Q46. Which is a drawback of microkernels?
a) More context switches
b) Slower performance
c) Complex message passing
d) All of the above
Answer: d
Q47. Which kernel architecture is most common in mobile OS?
a) Microkernel
b) Monolithic with modules
c) Hybrid kernel
d) Nanokernel
Answer: c
Q48. The kernel is responsible for switching between:
a) Programs and hardware
b) Tasks and processes
c) Kernel mode and user mode
d) All of the above
Answer: d
Q49. Which part of the kernel interacts directly with CPU scheduling?
a) Scheduler
b) Loader
c) Dispatcher
d) Task manager
Answer: a
Q50. The main security function of a kernel is:
a) Controlling access to hardware
b) Preventing hacking
c) Encrypting passwords
d) Detecting viruses
Answer: a
Topic 2 – Functions of Operating System (50 MCQs)
1. Which of the following is NOT a function of an OS?
a) Process management
b) Memory management
c) Compiling code
d) File management
Answer: c
Explanation: Compiling is done by compilers, not the OS.
2. The OS function that allocates CPU to processes is called:
a) Deadlock handling
b) Scheduling
c) Multiprocessing
d) Paging
Answer: b
Explanation: Scheduling decides which process gets CPU time.
3. Which OS function ensures that a program does not access memory of another program?
a) Memory protection
b) Deadlock prevention
c) File locking
d) Multiprogramming
Answer: a
Explanation: Memory protection stops illegal memory access.
4. File management includes:
a) Creating, deleting, and modifying files
b) Allocating CPU
c) Controlling I/O devices
d) Preventing deadlock
Answer: a
Explanation: File management handles all file-related operations.
5. Which OS function manages device communication?
a) Device management
b) Memory management
c) Process management
d) Scheduling
Answer: a
Explanation: Device management controls I/O devices and drivers.
6. The OS provides ______ to make interaction easier for users.
a) User interface
b) Compiler
c) Microcode
d) Hardware
Answer: a
Explanation: UI can be CLI or GUI.
7. The OS stores frequently used instructions in:
a) RAM
b) Cache
c) ROM
d) Registers
Answer: b
Explanation: Cache improves performance by storing frequently accessed data.
8. Which OS function is responsible for handling deadlocks?
a) Device management
b) Process management
c) Deadlock detection and recovery
d) Memory allocation
Answer: c
Explanation: Deadlock handling ensures smooth resource allocation.
9. Which component of OS translates user commands into actions?
a) Shell
b) Kernel
c) Loader
d) Compiler
Answer: a
Explanation: Shell interprets commands from the user.
10. Virtual memory is managed by:
a) File system
b) Memory manager
c) Device drivers
d) Loader
Answer: b
Explanation: Memory management unit handles virtual memory.
11. Which is NOT a process management task?
a) Process scheduling
b) Synchronization
c) Context switching
d) File encryption
Answer: d
Explanation: File encryption is part of file security, not process management.
12. OS ensures fair resource allocation through:
a) Scheduling algorithms
b) Deadlock prevention
c) File management
d) Booting
Answer: a
Explanation: Scheduling ensures fairness.
13. Which function of OS helps protect data from unauthorized access?
a) Scheduling
b) Security management
c) Paging
d) Swapping
Answer: b
Explanation: Security management includes authentication and permissions.
14. The OS loads a program into memory using:
a) Loader
b) Compiler
c) Scheduler
d) File Manager
Answer: a
Explanation: Loader loads executable files into memory.
15. Which OS function prevents multiple processes from interfering with each other?
a) Process isolation
b) Deadlock detection
c) Multithreading
d) Paging
Answer: a
Explanation: Isolation ensures processes run independently.
16. Spooling is used by OS to:
a) Speed up CPU
b) Manage printing tasks
c) Handle paging
d) Allocate memory
Answer: b
Explanation: Spooling stores print jobs in a buffer before printing.
17. Which OS function detects hardware failure?
a) Device management
b) Error detection
c) Deadlock detection
d) Swapping
Answer: b
Explanation: OS monitors hardware for failures.
18. The OS keeps track of files using:
a) File descriptor
b) Page table
c) Scheduler
d) PCB
Answer: a
Explanation: File descriptor contains file-related metadata.
19. Context switching is part of:
a) File management
b) Process management
c) Memory management
d) Device management
Answer: b
Explanation: Context switching changes CPU from one process to another.
20. The OS maintains information about each process in:
a) PCB (Process Control Block)
b) FAT (File Allocation Table)
c) Page table
d) Inode
Answer: a
Explanation: PCB stores process details like ID, state, registers, etc.
21. Which OS function manages RAM allocation to processes?
a) Process management
b) Memory management
c) Device management
d) File management
Answer: b
Explanation: Memory management handles allocation and deallocation of RAM.
22. The OS prevents programs from modifying the OS itself using:
a) Dual-mode operation
b) Swapping
c) Spooling
d) Deadlock prevention
Answer: a
Explanation: Dual-mode (user mode & kernel mode) protects OS code.
23. Which OS function handles multitasking?
a) Memory management
b) Process scheduling
c) File encryption
d) Deadlock prevention
Answer: b
Explanation: Scheduling enables multiple tasks to share CPU time.
24. Which OS function is responsible for providing APIs to applications?
a) Device management
b) System calls interface
c) Security management
d) Paging
Answer: b
Explanation: System calls provide an interface between programs and OS.
25. A mechanism that allows multiple processes to access a single resource safely is:
a) Synchronization
b) Scheduling
c) Deadlock prevention
d) Paging
Answer: a
Explanation: Synchronization prevents race conditions.
26. The OS organizes storage into:
a) Pages
b) Files and directories
c) Frames
d) Buffers
Answer: b
Explanation: File system organizes data in files and folders.
27. Which OS function maintains a list of free memory blocks?
a) Device drivers
b) Memory manager
c) Scheduler
d) File manager
Answer: b
Explanation: Memory manager tracks free and allocated memory.
28. In I/O management, the OS uses ______ to handle devices uniformly.
a) Device drivers
b) Kernels
c) Compilers
d) Schedulers
Answer: a
Explanation: Device drivers act as translators between OS and hardware.
29. Which of the following is NOT part of device management?
a) Device allocation
b) Spooling
c) Buffering
d) Paging
Answer: d
Explanation: Paging belongs to memory management.
30. Which OS function ensures efficient disk space usage?
a) File management
b) Process management
c) Virtual memory
d) Scheduling
Answer: a
Explanation: File management avoids fragmentation and waste.
31. Which OS function allows running older applications on new hardware?
a) Compatibility
b) Virtual memory
c) Multithreading
d) Synchronization
Answer: a
Explanation: Compatibility lets old programs run smoothly.
32. What is the role of the OS in communication between processes?
a) Interprocess communication (IPC)
b) Paging
c) Spooling
d) Fragmentation
Answer: a
Explanation: IPC lets processes exchange data.
33. Which OS function assigns resources to processes?
a) Resource allocation
b) Security
c) File encryption
d) Scheduling
Answer: a
Explanation: The OS decides which process gets which resource.
34. Which OS function ensures that the system runs smoothly without overload?
a) Load balancing
b) Spooling
c) Buffering
d) Swapping
Answer: a
Explanation: Load balancing distributes workload.
35. Which OS function starts immediately after the boot loader runs?
a) Kernel initialization
b) Process scheduling
c) Paging
d) File management
Answer: a
Explanation: Kernel loads into memory and starts OS services.
36. Which OS component directly interacts with hardware?
a) Kernel
b) Shell
c) Compiler
d) Loader
Answer: a
Explanation: The kernel manages hardware resources.
37. The OS helps prevent accidental overwriting of important data using:
a) File permissions
b) Paging
c) Deadlock prevention
d) Spooling
Answer: a
Explanation: Permissions control access.
38. The OS function that ensures fairness in CPU time distribution is:
a) Scheduling
b) Synchronization
c) Fragmentation
d) Spooling
Answer: a
Explanation: Scheduling allocates CPU fairly.
39. Which OS function deals with swapping processes in and out of memory?
a) Memory management
b) Device management
c) File management
d) Process synchronization
Answer: a
Explanation: Swapping is part of memory management.
40. The OS provides an environment for executing programs, known as:
a) Execution environment
b) Kernel space
c) CPU scheduler
d) Virtual machine
Answer: a
Explanation: The execution environment runs user applications.
41. Which OS function recovers from unexpected program termination?
a) Error handling
b) Swapping
c) Paging
d) Scheduling
Answer: a
Explanation: Error handling restores stability.
42. Which OS service allows multiple programs to share the same physical memory?
a) Virtual memory
b) Multiprocessing
c) Multithreading
d) Paging
Answer: a
Explanation: Virtual memory maps logical addresses to physical ones.
43. Which OS function controls execution of programs?
a) Process management
b) Device management
c) File management
d) Boot management
Answer: a
Explanation: Process management handles execution.
44. The OS function that allows files to be organized into directories is:
a) File management
b) Memory management
c) Process scheduling
d) Deadlock handling
Answer: a
Explanation: File management creates folder structures.
45. Which OS function deals with granting or denying access to files?
a) Security
b) Scheduling
c) Virtualization
d) Multiprogramming
Answer: a
Explanation: Security sets file access permissions.
46. The OS service that provides logging and auditing is part of:
a) Security management
b) File management
c) Process management
d) Memory management
Answer: a
Explanation: Security logs track activities.
47. Which OS function reduces CPU idle time?
a) Multiprogramming
b) Fragmentation
c) Paging
d) Spooling
Answer: a
Explanation: Multiprogramming ensures CPU always has work.
48. The OS translates virtual addresses to physical addresses via:
a) Memory management unit (MMU)
b) Scheduler
c) Loader
d) File system
Answer: a
Explanation: MMU handles address translation.
49. Which OS function improves performance by preloading data into memory?
a) Caching
b) Paging
c) Spooling
d) Fragmentation
Answer: a
Explanation: Caching stores frequently accessed data.
50. Which OS function ensures only authorized programs can run?
a) Security & authentication
b) Paging
c) Scheduling
d) Synchronization
Answer: a
Explanation: Security checks program authenticity.
Topic 3 – Classification of Operating System (50 MCQs)
1. Which type of OS allows only one process to run at a time?
a) Batch OS
b) Multiprogramming OS
c) Single-tasking OS
d) Distributed OS
Answer: c
Explanation: Single-tasking OS handles one task at a time.
2. Which OS processes jobs in batches without user interaction?
a) Real-time OS
b) Batch OS
c) Time-sharing OS
d) Distributed OS
Answer: b
Explanation: Batch OS executes a set of jobs together without user interaction.
3. An OS that shares CPU time equally among all processes is:
a) Real-time OS
b) Batch OS
c) Time-sharing OS
d) Single-tasking OS
Answer: c
Explanation: Time-sharing OS gives small time slices to each process.
4. Which OS responds to input within a guaranteed time?
a) Real-time OS
b) Multiprogramming OS
c) Batch OS
d) Time-sharing OS
Answer: a
Explanation: Real-time OS has predictable response times.
5. Windows is an example of:
a) Real-time OS
b) Multiprogramming OS
c) Single-user, multitasking OS
d) Batch OS
Answer: c
Explanation: Windows supports multiple tasks for a single user.
6. Which OS runs on multiple computers and appears as a single system?
a) Network OS
b) Distributed OS
c) Multiprogramming OS
d) Batch OS
Answer: b
Explanation: Distributed OS connects multiple machines into one system view.
7. Linux is classified as:
a) Single-user OS
b) Multiuser, multitasking OS
c) Batch OS
d) Real-time OS
Answer: b
Explanation: Linux supports multiple users and multitasking.
8. Which OS type is used in embedded systems?
a) Time-sharing OS
b) Batch OS
c) Real-time OS
d) Distributed OS
Answer: c
Explanation: Embedded systems need predictable real-time responses.
9. Which is an example of a batch processing OS?
a) MS-DOS
b) UNIX
c) IBM OS/360
d) Windows 10
Answer: c
Explanation: IBM OS/360 was a popular batch OS.
10. Multiprogramming OS improves:
a) CPU utilization
b) File management
c) User interface
d) Disk speed
Answer: a
Explanation: It runs multiple programs to keep CPU busy.
11. In time-sharing OS, CPU time is divided into:
a) Pages
b) Frames
c) Time slices
d) Segments
Answer: c
Explanation: Time slices are allocated to each process.
12. Which OS allows multiple users to work simultaneously?
a) Single-user OS
b) Multiuser OS
c) Batch OS
d) Real-time OS
Answer: b
Explanation: Multiuser OS manages simultaneous access for multiple users.
13. UNIX is an example of:
a) Multiuser, multitasking OS
b) Batch OS
c) Real-time OS
d) Single-tasking OS
Answer: a
Explanation: UNIX supports multiple users and tasks.
14. The main advantage of batch processing is:
a) Immediate output
b) No need for user interaction
c) Real-time responses
d) Low CPU usage
Answer: b
Explanation: Batch processing is fully automated once jobs are submitted.
15. Real-time OS used in aircraft is:
a) Soft real-time
b) Hard real-time
c) Batch OS
d) Time-sharing OS
Answer: b
Explanation: Hard real-time OS meets strict deadlines.
16. Soft real-time OS is used in:
a) Flight control systems
b) Video streaming
c) Banking systems
d) Compiler design
Answer: b
Explanation: Soft real-time tolerates some delay.
17. Which OS is designed for parallel computing?
a) Network OS
b) Distributed OS
c) Batch OS
d) Real-time OS
Answer: b
Explanation: Distributed OS manages parallel tasks across multiple machines.
18. Which type of OS is Windows Server?
a) Multiuser OS
b) Real-time OS
c) Single-tasking OS
d) Batch OS
Answer: a
Explanation: Windows Server supports multiple users simultaneously.
19. Mobile operating systems like Android are:
a) Real-time OS
b) Single-tasking OS
c) Multiuser, multitasking OS
d) Batch OS
Answer: c
Explanation: Android supports multitasking and multiple accounts.
20. Which OS is best suited for robotics control?
a) Time-sharing OS
b) Real-time OS
c) Batch OS
d) Multiuser OS
Answer: b
Explanation: Robotics needs precise timing — real-time OS..
21. Which OS type is best for supercomputers?
a) Single-user OS
b) Real-time OS
c) Distributed OS
d) Batch OS
Answer: c
Explanation: Distributed OS can manage high-performance parallel processing.
22. Which OS is commonly used for banking ATMs?
a) Batch OS
b) Real-time OS
c) Time-sharing OS
d) Single-tasking OS
Answer: b
Explanation: ATMs require quick, real-time transaction processing.
23. Which OS type is suitable for mainframes in the 1960s?
a) Time-sharing OS
b) Distributed OS
c) Batch OS
d) Real-time OS
Answer: c
Explanation: Early mainframes used batch OS for processing large jobs.
24. Which OS manages multiple CPUs efficiently?
a) Network OS
b) Multiprocessor OS
c) Batch OS
d) Single-tasking OS
Answer: b
Explanation: Multiprocessor OS coordinates multiple CPUs.
25. The main goal of multiprogramming OS is to:
a) Increase CPU utilization
b) Reduce I/O devices
c) Improve graphics performance
d) Reduce memory usage
Answer: a
Explanation: Multiprogramming reduces idle CPU time.
26. Which is an example of a real-time OS for aerospace?
a) VxWorks
b) UNIX
c) MS-DOS
d) Android
Answer: a
Explanation: VxWorks is used in aerospace and defense.
27. Which OS type works on multiple terminals?
a) Single-user OS
b) Multiuser OS
c) Real-time OS
d) Batch OS
Answer: b
Explanation: Multiuser OS supports many terminals.
28. Which OS category is designed for scientific experiments?
a) Real-time OS
b) Batch OS
c) Time-sharing OS
d) Distributed OS
Answer: a
Explanation: Scientific experiments often require real-time results.
29. MS-DOS belongs to which category?
a) Single-tasking OS
b) Multiuser OS
c) Real-time OS
d) Distributed OS
Answer: a
Explanation: MS-DOS runs one program at a time.
30. Which OS allows multiple programs to share CPU time fairly?
a) Batch OS
b) Time-sharing OS
c) Single-tasking OS
d) Real-time OS
Answer: b
Explanation: Time-sharing allocates time slices to processes.
31. Which is a disadvantage of batch OS?
a) High CPU usage
b) High memory requirements
c) No immediate user interaction
d) Fast processing
Answer: c
Explanation: Users can’t interact with programs while running.
32. Which OS runs processes sequentially without overlap?
a) Batch OS
b) Multiprogramming OS
c) Single-tasking OS
d) Real-time OS
Answer: c
Explanation: Single-tasking OS processes one task at a time.
33. UNIX time-sharing system was developed at:
a) Microsoft
b) Bell Labs
c) IBM
d) MIT
Answer: b
Explanation: UNIX was created at Bell Labs.
34. Which OS type is designed for continuous monitoring systems?
a) Batch OS
b) Real-time OS
c) Distributed OS
d) Network OS
Answer: b
Explanation: Real-time OS continuously monitors and controls events.
35. Which OS is mainly used in military applications?
a) Batch OS
b) Soft real-time OS
c) Hard real-time OS
d) Single-tasking OS
Answer: c
Explanation: Military systems require hard real-time responses.
36. Time-sharing OS was introduced to:
a) Improve memory
b) Reduce CPU idle time
c) Allow multiple users simultaneous access
d) Enhance file security
Answer: c
Explanation: Time-sharing supports many users at once.
37. The main advantage of a distributed OS is:
a) Centralized control
b) Resource sharing across machines
c) Faster single program execution
d) Better graphics
Answer: b
Explanation: Distributed OS shares resources across systems.
38. Which OS handles both interactive and background jobs?
a) Batch OS
b) Multiprogramming OS
c) Real-time OS
d) Single-tasking OS
Answer: b
Explanation: Multiprogramming supports multiple tasks at once.
39. An OS for large-scale industrial control is:
a) Real-time OS
b) Batch OS
c) Single-tasking OS
d) Time-sharing OS
Answer: a
Explanation: Real-time OS is crucial for controlling machinery.
40. Which OS type can survive failure of one machine without affecting others?
a) Batch OS
b) Distributed OS
c) Single-tasking OS
d) Time-sharing OS
Answer: b
Explanation: Distributed OS has fault tolerance.
41. In multiuser OS, each user gets:
a) A separate CPU
b) Shared resources
c) Exclusive access to memory
d) No file sharing
Answer: b
Explanation: Resources are shared between users.
42. Which is an example of a network OS?
a) Windows NT
b) UNIX
c) VxWorks
d) MS-DOS
Answer: a
Explanation: Windows NT supports networking features.
43. Which OS type improves CPU and I/O device utilization?
a) Single-tasking OS
b) Multiprogramming OS
c) Batch OS
d) Distributed OS
Answer: b
Explanation: Multiprogramming overlaps CPU and I/O.
44. Which OS type can handle thousands of users simultaneously?
a) Multiuser OS
b) Single-user OS
c) Batch OS
d) Real-time OS
Answer: a
Explanation: Multiuser OS is designed for scalability.
45. Which OS is most suited for railway ticket booking systems?
a) Batch OS
b) Real-time OS
c) Single-tasking OS
d) Multiprogramming OS
Answer: b
Explanation: Real-time ensures up-to-date ticket availability.
46. In which OS type is turnaround time very important?
a) Batch OS
b) Real-time OS
c) Time-sharing OS
d) Single-tasking OS
Answer: b
Explanation: Real-time OS needs immediate results.
47. Which OS category includes Google’s Chrome OS?
a) Real-time OS
b) Network OS
c) Multiuser OS
d) Distributed OS
Answer: c
Explanation: Chrome OS supports multiple accounts and multitasking.
48. Which is a limitation of single-user OS?
a) Can’t multitask
b) Can’t boot from disk
c) No file storage
d) No memory management
Answer: a
Explanation: Single-user OS runs one process at a time.
49. A batch OS executes:
a) Multiple users interactively
b) A series of jobs without interaction
c) Programs one at a time
d) Real-time programs
Answer: b
Explanation: Jobs are processed together in batches.
50. Which OS is used for space shuttle control?
a) Batch OS
b) Hard real-time OS
c) Soft real-time OS
d) Multiprogramming OS
Answer: b
Explanation: Space shuttle systems require strict timing.
Topic 4 – Process Scheduling (50 MCQs)
1. Process scheduling is concerned with:
a) Allocating CPU to processes
b) Allocating memory to processes
c) Allocating I/O devices
d) Allocating files
Answer: a
Explanation: Scheduling decides which process gets CPU time.
2. Which scheduling is used by operating systems to decide which process runs next?
a) File scheduling
b) Process scheduling
c) Disk scheduling
d) Memory scheduling
Answer: b
Explanation: Process scheduling selects processes for execution.
3. FCFS scheduling stands for:
a) First-Come, First-Serve
b) First-Count, First-Serve
c) First-Compute, First-Save
d) First-Come, First-Save
Answer: a
Explanation: FCFS runs processes in order of arrival.
4. In FCFS scheduling, the average waiting time can be:
a) High
b) Always low
c) Zero
d) Negative
Answer: a
Explanation: Long processes at the front increase waiting time.
5. Which scheduling gives priority to the shortest job first?
a) FCFS
b) SJF
c) RR
d) Priority
Answer: b
Explanation: Shortest Job First (SJF) chooses the shortest burst time.
6. SJF scheduling may cause:
a) Starvation
b) Deadlock
c) Fragmentation
d) Thrashing
Answer: a
Explanation: Long processes may starve if short jobs keep arriving.
7. Which scheduling algorithm gives each process a fixed time slice?
a) SJF
b) RR
c) FCFS
d) Priority
Answer: b
Explanation: Round Robin uses time quantum for each process.
8. In Round Robin scheduling, a smaller time quantum:
a) Reduces context switching
b) Increases response time
c) Increases context switching
d) Improves CPU utilization
Answer: c
Explanation: Too small quantum increases switching overhead.
9. Which scheduling is most suitable for time-sharing systems?
a) FCFS
b) SJF
c) RR
d) Priority
Answer: c
Explanation: RR ensures all processes get CPU fairly in time-sharing.
10. Priority scheduling can be:
a) Preemptive
b) Non-preemptive
c) Both a and b
d) Neither
Answer: c
Explanation: Priority scheduling can work in either mode.
11. In priority scheduling, starvation occurs when:
a) Low-priority processes never get CPU
b) High-priority processes never get CPU
c) All processes wait equally
d) None of these
Answer: a
Explanation: Low-priority processes may wait indefinitely.
12. A solution to priority scheduling starvation is:
a) Deadlock avoidance
b) Aging
c) Thrashing
d) Fragmentation
Answer: b
Explanation: Aging gradually increases a process’s priority.
13. Turnaround time is:
a) Completion time – Arrival time
b) Waiting time + Arrival time
c) Burst time – Waiting time
d) None of these
Answer: a
Explanation: Turnaround time measures total time from arrival to completion.
14. Waiting time is:
a) Turnaround time – Burst time
b) Completion time – Burst time
c) Arrival time – Completion time
d) None of these
Answer: a
Explanation: Waiting time excludes actual execution time.
15. In preemptive scheduling:
a) Process is not interrupted
b) Process can be interrupted
c) Processes run in arrival order
d) None of these
Answer: b
Explanation: Preemptive scheduling allows stopping a process to run another.
16. Which of these is a non-preemptive scheduling algorithm?
a) SJF
b) Priority
c) FCFS
d) RR
Answer: c
Explanation: FCFS never preempts a running process.
17. Multi-level queue scheduling divides processes based on:
a) Arrival time
b) Priority or type
c) CPU speed
d) Memory size
Answer: b
Explanation: It groups processes into queues by priority/type.
18. CPU-bound processes are:
a) Processes that spend most time on I/O
b) Processes that spend most time on CPU
c) Processes with low burst time
d) None of these
Answer: b
Explanation: CPU-bound processes use CPU heavily.
19. I/O-bound processes are:
a) Always short
b) Processes that spend more time on I/O
c) Processes that use CPU heavily
d) None of these
Answer: b
Explanation: I/O-bound processes often wait for I/O devices.
20. Which scheduling aims to maximize CPU utilization and throughput?
a) FCFS
b) SJF
c) Priority
d) All of these
Answer: d
Explanation: All aim to optimize performance metrics.
21. Context switching occurs when:
a) CPU switches from one process to another
b) Process starts execution
c) Process ends
d) None of these
Answer: a
Explanation: Context switching saves and loads process states.
22. Which scheduling algorithm is optimal for minimizing average waiting time?
a) FCFS
b) SJF (non-preemptive)
c) RR
d) Priority
Answer: b
Explanation: SJF minimizes average waiting time.
23. The main drawback of SJF scheduling is:
a) Complex to implement
b) Requires knowledge of next CPU burst time
c) Higher turnaround time
d) None of these
Answer: b
Explanation: Burst time prediction is difficult.
24. Throughput is measured in:
a) Processes per minute/hour
b) Seconds per process
c) Bytes per second
d) None of these
Answer: a
Explanation: Throughput is the number of processes completed per unit time.
25. Response time is:
a) Time from submission to first output
b) Time from submission to completion
c) Time taken to complete a process
d) None of these
Answer: a
Explanation: Response time measures system’s responsiveness.
26. Which is NOT a scheduling criterion?
a) CPU utilization
b) Throughput
c) Power consumption
d) Waiting time
Answer: c
Explanation: Power consumption is not a standard CPU scheduling metric.
27. Preemptive SJF is also called:
a) Longest Job First
b) Shortest Remaining Time First
c) Round Robin
d) Priority Scheduling
Answer: b
Explanation: It chooses the process with least remaining burst time.
28. Which algorithm is prone to convoy effect?
a) FCFS
b) SJF
c) RR
d) Priority
Answer: a
Explanation: Long processes delay shorter ones.
29. Aging prevents:
a) Deadlock
b) Starvation
c) Fragmentation
d) Thrashing
Answer: b
Explanation: It increases waiting process priority over time.
30. In Round Robin, if time quantum is too large, it becomes:
a) FCFS
b) SJF
c) Priority Scheduling
d) Multi-level Queue
Answer: a
Explanation: Large quantum behaves like FCFS.
31. Which scheduling is best for real-time systems?
a) FCFS
b) SJF
c) RR
d) Priority scheduling
Answer: d
Explanation: Priorities ensure critical tasks run first.
32. CPU scheduling occurs when:
a) Process switches from running to waiting
b) Process switches from running to ready
c) Process switches from waiting to ready
d) All of these
Answer: d
Explanation: Scheduling happens in all these cases.
33. Non-preemptive scheduling decisions are made only when:
a) Process terminates
b) Process switches from running to waiting
c) Both a and b
d) None of these
Answer: c
Explanation: CPU is released voluntarily.
34. Which algorithm may lead to indefinite blocking?
a) FCFS
b) SJF
c) Priority Scheduling
d) RR
Answer: c
Explanation: Low-priority jobs may starve.
35. Which metric is NOT directly affected by scheduling algorithms?
a) Throughput
b) Waiting time
c) Burst time
d) Turnaround time
Answer: c
Explanation: Burst time is fixed for a process.
36. Which scheduling algorithm uses multiple queues with different scheduling algorithms?
a) Multi-level feedback queue
b) Multi-level queue
c) RR
d) SJF
Answer: a
Explanation: MLFBQ allows movement between queues.
37. Which is an example of preemptive scheduling?
a) FCFS
b) RR
c) Non-preemptive SJF
d) Non-preemptive Priority
Answer: b
Explanation: RR interrupts after each quantum.
38. The dispatcher’s role is to:
a) Load processes from disk
b) Assign CPU to the selected process
c) Manage memory allocation
d) Handle I/O
Answer: b
Explanation: Dispatcher gives control of CPU to process.
39. Dispatcher latency is:
a) Time taken to load OS
b) Time taken to switch CPU to user process
c) Time taken to execute a process
d) Time taken for I/O
Answer: b
Explanation: It’s the time between context switch and process execution.
40. Time quantum in RR should be:
a) Very small
b) Very large
c) Moderate
d) Zero
Answer: c
Explanation: It balances response time and context switching.
41. Longest Job First (LJF) scheduling is:
a) Preemptive only
b) Non-preemptive only
c) Both preemptive and non-preemptive
d) None of these
Answer: c
Explanation: LJF can be implemented in both modes.
42. In which case do we need CPU scheduling the most?
a) Single process system
b) Multiprogramming
c) Batch processing
d) None of these
Answer: b
Explanation: Multiprogramming requires CPU sharing.
43. Which one is a hybrid scheduling algorithm?
a) Multi-level feedback queue
b) SJF
c) FCFS
d) Priority
Answer: a
Explanation: It combines multiple strategies.
44. The main advantage of RR over FCFS is:
a) Higher throughput
b) Better average turnaround time
c) Better response time
d) Less context switching
Answer: c
Explanation: RR responds faster to interactive tasks.
45. Which algorithm is suitable for batch processing?
a) FCFS
b) RR
c) Priority
d) Multi-level queue
Answer: a
Explanation: FCFS is simple and fair for batch jobs.
46. CPU utilization is:
a) % of time CPU is busy
b) % of time CPU is idle
c) Number of processes completed per second
d) None of these
Answer: a
Explanation: It measures CPU activity.
47. Turnaround time = Waiting time + _______?
a) Burst time
b) Response time
c) Completion time
d) Arrival time
Answer: a
Explanation: Turnaround includes both waiting and execution.
48. Which metric should be minimized in time-sharing systems?
a) Waiting time
b) Response time
c) Throughput
d) CPU utilization
Answer: b
Explanation: Users expect quick responses.
49. Which algorithm suffers most from the convoy effect?
a) FCFS
b) SJF
c) RR
d) Priority
Answer: a
Explanation: One long job delays many short jobs.
50. In scheduling, fairness means:
a) All processes get equal CPU time over time
b) High-priority jobs always execute first
c) Processes execute in FCFS order
d) None of these
Answer: a
Explanation: Fairness ensures no process starves.
Topic 5 – Memory Management (50 MCQs)
1. Which of the following is NOT a memory management technique?
a) Paging
b) Segmentation
c) Swapping
d) Scheduling
Answer: d
Explanation: Scheduling is part of process management, not memory management.
2. In paging, memory is divided into fixed-size blocks called:
a) Pages
b) Frames
c) Segments
d) Blocks
Answer: a
Explanation: Logical memory is divided into pages; physical memory into frames.
3. Which memory allocation method suffers from external fragmentation?
a) Paging
b) Segmentation
c) Fixed partitioning
d) Variable partitioning
Answer: d
Explanation: Variable partitioning may leave small unusable memory holes.
4. Internal fragmentation occurs in:
a) Variable-sized allocation
b) Fixed-sized allocation
c) Virtual memory
d) Demand paging
Answer: b
Explanation: Fixed-size blocks may waste unused space inside blocks.
5. Which memory is fastest to access?
a) Cache memory
b) Main memory
c) Virtual memory
d) Secondary storage
Answer: a
Explanation: Cache is closest to the CPU.
6. Virtual memory allows:
a) CPU to run without RAM
b) Execution of larger programs than physical memory
c) More I/O operations
d) Faster CPU speed
Answer: b
Explanation: It extends available memory using disk space.
7. Thrashing occurs when:
a) CPU is idle
b) Too much paging happens
c) No process is ready
d) Deadlock occurs
Answer: b
Explanation: Thrashing happens when paging overhead is very high.
8. Which algorithm replaces the page that will not be used for the longest period of time?
a) FIFO
b) LRU
c) Optimal
d) Clock
Answer: c
Explanation: Optimal algorithm is theoretical best.
9. In LRU page replacement, the page replaced is:
a) Recently used
b) Least recently used
c) Most frequently used
d) Randomly chosen
Answer: b
Explanation: LRU removes the page unused for the longest recent time.
10. Demand paging loads pages:
a) Before they are needed
b) When they are needed
c) Randomly
d) At boot time
Answer: b
Explanation: Reduces memory usage by loading on demand.
11. The page table stores:
a) Process IDs
b) Mapping between pages and frames
c) Disk addresses
d) File names
Answer: b
Explanation: It translates logical to physical addresses.
12. Segmentation divides memory based on:
a) Equal sizes
b) Process needs
c) Logical divisions like functions and arrays
d) Random partitions
Answer: c
Explanation: Segments vary in size and are based on logical program structure.
13. The swapping technique is used to:
a) Allocate more CPU
b) Bring processes in/out of memory
c) Prevent deadlock
d) Schedule jobs
Answer: b
Explanation: Swapping moves processes between RAM and disk.
14. Which memory is non-volatile?
a) RAM
b) ROM
c) Cache
d) Registers
Answer: b
Explanation: ROM retains data without power.
15. The working set model helps prevent:
a) Internal fragmentation
b) External fragmentation
c) Thrashing
d) Deadlock
Answer: c
Explanation: It ensures enough frames for each process.
16. Physical addresses are generated by:
a) CPU directly
b) Memory management unit (MMU)
c) Secondary storage
d) I/O devices
Answer: b
Explanation: MMU translates logical to physical addresses.
17. Which allocation policy assigns the smallest block that fits?
a) First fit
b) Best fit
c) Worst fit
d) Next fit
Answer: b
Explanation: Best fit minimizes wasted space.
18. Which policy assigns the first free block available?
a) First fit
b) Best fit
c) Worst fit
d) Next fit
Answer: a
Explanation: First fit searches from the beginning.
19. Which policy assigns the largest available block?
a) First fit
b) Best fit
c) Worst fit
d) Next fit
Answer: c
Explanation: Worst fit may reduce future fragmentation.
20. Belady’s anomaly is related to:
a) Thrashing
b) Page faults increasing with more frames
c) Deadlock
d) CPU scheduling
Answer: b
Explanation: It occurs in FIFO page replacement.
21. In paging, the size of a page is always:
a) Variable
b) Fixed
c) Equal to process size
d) Equal to memory size
Answer: b
Explanation: Page size is fixed and set by hardware.
22. Which replacement algorithm uses a circular list of frames?
a) FIFO
b) LRU
c) Clock
d) Optimal
Answer: c
Explanation: Clock algorithm uses a circular buffer with a reference bit.
23. Page fault occurs when:
a) Page is found in memory
b) Page is not in memory
c) Disk fails
d) CPU halts
Answer: b
Explanation: Page fault triggers loading of the missing page from disk.
24. Effective memory access time depends on:
a) Page fault rate
b) Hit ratio
c) Memory access time
d) All of the above
Answer: d
Explanation: All these factors contribute.
25. In segmentation with paging, the address contains:
a) Segment number, page number, offset
b) Page number, frame number
c) Segment number, frame number
d) Only offset
Answer: a
Explanation: It combines both concepts.
26. Paging avoids:
a) Internal fragmentation
b) External fragmentation
c) Both
d) None
Answer: b
Explanation: Fixed-size pages eliminate external fragmentation.
27. Frame allocation algorithms determine:
a) CPU speed
b) How many frames to allocate to each process
c) Disk space usage
d) Cache replacement policy
Answer: b
Explanation: Helps avoid thrashing and optimize performance.
28. Dynamic loading means:
a) Entire program is loaded at once
b) Only required routines are loaded on demand
c) Loading from ROM
d) Memory is fixed
Answer: b
Explanation: Saves memory by loading when needed.
29. Which is NOT a page replacement policy?
a) FIFO
b) LRU
c) MRU
d) Round Robin
Answer: d
Explanation: Round Robin is a CPU scheduling policy.
30. What is the main disadvantage of segmentation?
a) Internal fragmentation
b) External fragmentation
c) Thrashing
d) Page faults
Answer: b
Explanation: Variable-sized segments cause external fragmentation.
31. Which register holds the starting address of the page table?
a) MAR
b) PTBR
c) IR
d) PC
Answer: b
Explanation: PTBR = Page Table Base Register.
32. Page size is usually a power of:
a) 2
b) 10
c) 4
d) 8
Answer: a
Explanation: Easier for binary address translation.
33. Which memory is volatile?
a) ROM
b) Hard disk
c) RAM
d) SSD
Answer: c
Explanation: RAM loses data when power is off.
34. Memory compaction is used to:
a) Increase CPU speed
b) Reduce external fragmentation
c) Prevent deadlock
d) Avoid page faults
Answer: b
Explanation: Compaction moves processes to remove small gaps.
35. Associative memory is also called:
a) Virtual memory
b) Translation lookaside buffer (TLB)
c) Cache memory
d) Main memory
Answer: b
Explanation: TLB stores recent page table entries.
36. The hit ratio is defined as:
a) Number of page faults / total accesses
b) Number of hits / total accesses
c) Number of frames / total pages
d) None
Answer: b
Explanation: It’s the fraction of accesses found in cache/TLB.
37. Which is faster:
a) Associative access
b) Sequential access
c) Direct access
d) All same
Answer: a
Explanation: Associative (parallel) search is fastest.
38. In demand segmentation:
a) Whole segment is loaded before execution
b) Segment is loaded only when needed
c) All segments are preloaded
d) None
Answer: b
Explanation: Works like demand paging but with segments.
39. The concept of locality of reference is used in:
a) CPU scheduling
b) Memory management
c) File allocation
d) I/O handling
Answer: b
Explanation: Programs tend to access a small part of memory repeatedly.
40. Translation time per memory reference can be reduced by:
a) Paging
b) TLB
c) Segmentation
d) Swapping
Answer: b
Explanation: TLB speeds up address translation.
41. In two-level paging, the logical address is divided into:
a) Page number, offset
b) Outer page number, inner page number, offset
c) Frame number, offset
d) Segment, offset
Answer: b
Explanation: Two-level paging reduces page table size.
42. Fixed partitioning suffers from:
a) Internal fragmentation
b) External fragmentation
c) Both
d) None
Answer: a
Explanation: Wasted space inside fixed partitions.
43. Variable partitioning suffers from:
a) Internal fragmentation
b) External fragmentation
c) Both
d) None
Answer: b
Explanation: Creates small gaps in memory.
44. Which algorithm replaces the page not used for the longest time in the past?
a) FIFO
b) LRU
c) Optimal
d) Clock
Answer: b
Explanation: LRU = Least Recently Used.
45. Which algorithm uses "reference bit" and "second chance"?
a) FIFO
b) Clock
c) LRU
d) Optimal
Answer: b
Explanation: Clock gives a second chance before replacement.
46. Demand paging is based on:
a) Virtual memory
b) Real memory only
c) Static allocation
d) Sequential execution
Answer: a
Explanation: Loads pages from disk when required.
47. Paging requires:
a) External fragmentation
b) Internal fragmentation
c) No fragmentation
d) None
Answer: b
Explanation: Last frame may be partially empty.
48. Best-fit allocation can lead to:
a) Large free blocks
b) Many small free blocks
c) No free space
d) Continuous memory
Answer: b
Explanation: Leaves small unusable holes.
49. Which of the following is a hardware component aiding memory management?
a) MMU
b) ALU
c) Control unit
d) Cache controller
Answer: a
Explanation: MMU handles address translation.
50. Which memory management strategy allows programs to be larger than physical memory?
a) Paging
b) Virtual memory
c) Fixed partitioning
d) Segmentation
Answer: b
Explanation: Uses disk as an extension of RAM.
Topic 6 – Deadlock (50 MCQs)
1. Deadlock is a situation where:
a) A process waits indefinitely for a resource held by another process
b) CPU is idle
c) Memory is full
d) I/O devices fail
Answer: a
Explanation: Deadlock occurs when processes are stuck waiting for each other.
2. Which of the following is NOT a necessary condition for deadlock?
a) Mutual exclusion
b) Hold and wait
c) Preemption
d) Circular wait
Answer: c
Explanation: No-preemption is required, not preemption.
3. Mutual exclusion means:
a) Only one process uses a resource at a time
b) Many processes can share a resource
c) Resource is preempted anytime
d) CPU scheduling is paused
Answer: a
Explanation: It’s an exclusive access condition.
4. Hold and wait means:
a) Process holds one resource and waits for others
b) Process waits without holding anything
c) Process releases all resources before waiting
d) Process runs without waiting
Answer: a
5. Circular wait means:
a) Resources are allocated in a chain such that each process waits for another
b) All processes wait in a queue
c) Deadlock prevention method
d) CPU round-robin scheduling
Answer: a
6. Which is NOT a method for handling deadlocks?
a) Prevention
b) Avoidance
c) Detection and recovery
d) Virtual memory
Answer: d
7. Deadlock prevention aims to:
a) Allow deadlock to happen
b) Ensure one of the necessary conditions never occurs
c) Recover after deadlock happens
d) Detect after occurrence
Answer: b
8. Deadlock avoidance needs:
a) Knowledge of future resource requests
b) No preemption
c) Circular wait
d) Starvation
Answer: a
9. The Banker’s algorithm is used for:
a) Deadlock detection
b) Deadlock prevention
c) Deadlock avoidance
d) Memory management
Answer: c
10. In Banker’s algorithm, a safe state means:
a) No deadlock is possible
b) Deadlock exists
c) Processes are blocked
d) CPU is idle
Answer: a
11. A wait-for graph is used in:
a) Deadlock detection
b) Deadlock prevention
c) Memory allocation
d) Paging
Answer: a
12. Wait-for graph contains:
a) Edges from processes to resources
b) Edges from process to process
c) Edges from resource to process
d) Pages and frames
Answer: b
13. If wait-for graph has a cycle in single-instance resource systems:
a) Deadlock exists
b) Deadlock possible but not certain
c) Deadlock impossible
d) Memory full
Answer: a
14. In multi-instance resource systems, a cycle in wait-for graph means:
a) Deadlock certain
b) Deadlock possible
c) Deadlock impossible
d) Memory overflow
Answer: b
15. Resource allocation graph with edges from resources to processes means:
a) Process is holding the resource
b) Process is requesting the resource
c) Deadlock
d) Safe state
Answer: a
16. In deadlock prevention, breaking the hold and wait condition is done by:
a) Forcing processes to request all resources at once
b) Allowing partial resource holding
c) Using virtual memory
d) Round-robin scheduling
Answer: a
17. Breaking the circular wait condition is done by:
a) Ordering resources
b) Increasing CPU speed
c) Paging
d) Multi-threading
Answer: a
18. Which deadlock handling method has the lowest resource utilization?
a) Prevention
b) Avoidance
c) Detection and recovery
d) None
Answer: a
19. Starvation is different from deadlock because:
a) Starvation eventually resolves
b) Deadlock eventually resolves
c) Starvation can be caused by scheduling
d) Both a and c
Answer: d
20. Which recovery method is most expensive?
a) Process termination
b) Resource preemption
c) Increasing priority
d) Multiprogramming
Answer: b
21. In deadlock recovery by process termination, the order of termination is usually based on:
a) Process priority
b) Process ID
c) Process holding the least resources
d) Process waiting for the shortest time
Answer: a
22. Which is NOT a factor when selecting a victim process in deadlock recovery?
a) Priority
b) Time to restart
c) Resources held
d) CPU temperature
Answer: d
23. Preemption in deadlock recovery means:
a) Taking resources from one process and giving to another
b) Stopping CPU scheduling
c) Restarting the OS
d) Disabling I/O
Answer: a
24. In resource allocation graph, which edges indicate waiting?
a) Process → Resource
b) Resource → Process
c) Both a and b
d) None
Answer: a
25. In a system with no preemption, deadlock is more:
a) Likely
b) Unlikely
c) Same as preemption
d) Impossible
Answer: a
26. Deadlock detection in single-instance resource systems uses:
a) Wait-for graph
b) Banker’s algorithm
c) Paging
d) Segmentation
Answer: a
27. In multi-instance resource systems, deadlock detection uses:
a) Wait-for graph
b) Detection algorithm similar to Banker’s
c) Demand paging
d) Thrashing
Answer: b
28. Which is the most restrictive method for avoiding deadlocks?
a) Prevention
b) Avoidance
c) Detection
d) Random allocation
Answer: a
29. The safe sequence in Banker’s algorithm is:
a) Sequence of processes that can finish without deadlock
b) Sequence of resources
c) Sequence of CPU bursts
d) Sequence of memory allocations
Answer: a
30. A deadlock can be resolved by:
a) Killing all processes
b) Rebooting
c) Preempting resources
d) All of the above
Answer: d
31. Circular wait can be prevented by:
a) Global ordering of resources
b) Priority inversion
c) Increasing CPU speed
d) Semaphore
Answer: a
32. Deadlock avoidance requires system to be:
a) Predictive
b) Reactive
c) Passive
d) Idle
Answer: a
33. The primary disadvantage of Banker’s algorithm is:
a) Requires advance knowledge of resource needs
b) Slow CPU speed
c) Needs virtual memory
d) Can’t detect deadlocks
Answer: a
34. In deadlock prevention by “request all at once” method:
a) Resource utilization is low
b) Resource utilization is high
c) Starvation is eliminated
d) CPU scheduling is faster
Answer: a
35. Which is TRUE about safe and unsafe states?
a) Unsafe state always leads to deadlock
b) Unsafe state may lead to deadlock
c) Safe state always leads to deadlock
d) Safe state means circular wait
Answer: b
36. The wait-for graph detection algorithm works for:
a) Single-instance resources only
b) Multi-instance resources only
c) Both a and b
d) Virtual memory
Answer: a
37. Which is an example of deadlock in real life?
a) Four cars stuck in a circular crossing
b) One-way street with no traffic
c) Bank account transfer success
d) Train arriving on time
Answer: a
38. Recovery from deadlock by process rollback requires:
a) Checkpoints
b) Paging
c) Thrashing
d) Semaphores
Answer: a
39. Which is NOT a deadlock prevention technique?
a) Resource ordering
b) Releasing resources before waiting
c) Disabling interrupts
d) Preempting resources
Answer: c
40. The detection algorithm for multi-instance systems is similar to:
a) Banker’s safety algorithm
b) LRU paging
c) FIFO scheduling
d) Belady’s anomaly
Answer: a
41. Which is NOT a Coffman condition?
a) Mutual exclusion
b) Hold and wait
c) Preemption
d) Circular wait
Answer: c
42. Which OS uses Banker’s algorithm?
a) General-purpose OS
b) Real-time OS
c) Database systems
d) All of these
Answer: c
43. Deadlock detection is preferred in:
a) Low resource utilization systems
b) High resource utilization systems
c) Batch processing systems
d) None
Answer: b
44. The main disadvantage of deadlock detection is:
a) Overhead of running detection algorithm
b) Low CPU speed
c) Needs virtual memory
d) Only works on UNIX
Answer: a
45. Which is NOT a possible deadlock recovery method?
a) Killing processes
b) Resource preemption
c) Reducing CPU speed
d) Process rollback
Answer: c
46. Deadlock and starvation are related because:
a) Both involve waiting
b) Both always occur together
c) Starvation causes deadlock
d) Deadlock causes starvation always
Answer: a
47. Which deadlock prevention method might cause starvation?
a) Preemption
b) Circular wait prevention
c) Hold and wait prevention
d) All of these
Answer: d
48. Deadlock in databases is usually handled by:
a) Wait-die or wound-wait schemes
b) Thrashing
c) Virtual memory
d) FIFO queues
Answer: a
49. In operating systems, deadlock is more likely when:
a) Resource utilization is high
b) Resource utilization is low
c) CPU is idle
d) Paging is used
Answer: a
50. The best strategy for avoiding deadlock in a real-time system is:
a) Resource ordering
b) Preempting resources
c) Priority-based avoidance
d) Using Banker’s algorithm
Answer: c
1) CPU Scheduling — Solved Numericals
Q1) FCFS – Average Waiting & Turnaround
Given: P1=24 ms, P2=3 ms, P3=3 ms (all arrive at 0), order: P1→P2→P3
Gantt: |--P1(0–24)--|--P2(24–27)--|--P3(27–30)--|
• Completion (CT): P1=24, P2=27, P3=30
• Turnaround (TAT=CT–AT): 24, 27, 30 → Avg TAT = (24+27+30)/3 = 81/3 = 27 ms
• Waiting (WT=TAT–BT): 0, 24, 27 → Avg WT = (0+24+27)/3 = 51/3 = 17 ms
Q2) SJF (Non-Preemptive) – With Arrivals
Given:
• P2: BT=8, AT=0
• P3: BT=7, AT=1
• P1: BT=6, AT=2
• P4: BT=3, AT=3
Schedule (choose shortest among arrived when CPU frees):
• 0–8: P2 → 8–11: P4 → 11–17: P1 → 17–24: P3
CT: P2=8, P4=11, P1=17, P3=24
TAT (CT–AT): P2=8, P4=8, P1=15, P3=23 → Avg TAT = (8+8+15+23)/4 = 54/4 = 13.5
WT (TAT–BT): P2=0, P4=5, P1=9, P3=16 → Avg WT = (0+5+9+16)/4 = 30/4 = 7.5
Q3) Round Robin (q = 4 ms)
Given (AT=0): P1=10, P2=5, P3=8
Slices:
• 0–4 P1(→6 left), 4–8 P2(→1), 8–12 P3(→4), 12–16 P1(→2), 16–17 P2(done), 17–21 P3(done), 21–23 P1(done)
CT: P1=23, P2=17, P3=21
TAT: 23, 17, 21 → Avg TAT = (23+17+21)/3 = 61/3 = 20.33
WT (TAT–BT): 13, 12, 13 → Avg WT = (13+12+13)/3 = 38/3 = 12.67
Response time: P1=0, P2=4, P3=8
Q4) Priority (Non-Preemptive; lower number = higher priority)
Given (AT=0):
• P2: BT=1, Pr=1
• P5: BT=5, Pr=2
• P1: BT=10, Pr=3
• P3: BT=2, Pr=4
• P4: BT=1, Pr=5
Order: P2 → P5 → P1 → P3 → P4
CT: 1, 6, 16, 18, 19
TAT: 1, 6, 16, 18, 19 → Avg TAT = 60/5 = 12.0
WT (TAT–BT): 0, 1, 6, 16, 18 → Avg WT = 41/5 = 8.2
2) Memory Management — Solved Numericals
Q5) FIFO Page Replacement — Page Faults
Frames=3; Reference: 7,0,1,2,0,3,0,4,2,3,0,3
Result (with FIFO pointer): Faults at 7,0,1,2,3,0,4,2,3,0 → 10 faults (hits at the other two).
Q6) LRU Page Replacement — Page Faults
Frames=3; Reference: 1,2,3,4,1,2,5,1,2,3,4,5
Track most-recently used; replace least-recent.
Faults: at 1,2,3,4,1,2,5,3,4,5 → 10 faults.
Q7) Optimal Page Replacement — Page Faults
Frames=3; Same reference: 1,2,3,4,1,2,5,1,2,3,4,5
Look ahead; evict page used farthest in future.
Faults: at 1,2,3,4,5,3,4 → 7 faults (minimum possible).
Q8) Effective Memory Access Time (EMAT)
Given: page-fault rate p=0.01p=0.01p=0.01, memory access =200=200=200 ns, page-fault service =8=8=8 ms
=8,000,000=8{,}000{,}000=8,000,000 ns
EMAT=(1−p)×200+p×8,000,000=0.99×200+0.01×8,000,000=198+80,000=80,198 ns≈80.198 μs\text{EMAT}=(1-p)\times 200 + p \times
8{,}000{,}000 =0.99\times 200 + 0.01\times 8{,}000{,}000 =198 + 80{,}000 = \mathbf{80{,}198\ \text{ns}} \approx \mathbf{80.198\ \mu
s}EMAT=(1−p)×200+p×8,000,000=0.99×200+0.01×8,000,000=198+80,000=80,198 ns≈80.198 μs
Q9) Internal Fragmentation with Best-Fit
Blocks (KB): 100, 500, 200, 300, 600
Processes (KB): 212, 417, 112, 426 (allocate in this order, best-fit)
• P1=212 → best fit 300 → frag 300−212 = 88
• P2=417 → best fit 500 → frag 500−417 = 83
• P3=112 → best fit 200 → frag 200−112 = 88
• P4=426 → best fit 600 → frag 600−426 = 174
Total internal fragmentation = 88+83+88+174 = 433 KB\mathbf{433\ KB}433 KB
(External frag: a 100 KB block remains unused.)
3) Deadlock — Solved Numericals
Q10) Banker’s Algorithm — Safety Check
Resource types: A,B,C
Available: [3,3,2][3,3,2][3,3,2]
Allocation
P0:[0,1,0] P1:[2,0,0] P2:[3,0,2] P3:[2,1,1] P4:[0,0,2]
Max
P0:[7,5,3] P1:[3,2,2] P2:[9,0,2] P3:[2,2,2] P4:[4,3,3]
Need = Max − Allocation
P0:[7,4,3] P1:[1,2,2] P2:[6,0,0] P3:[0,1,1] P4:[4,3,1]
Work=Available=[3,3,2], Finish all = false
• Pick P1 (Need≤Work): Work←[5,3,2]
• Pick P3: Work←[7,4,3]
• Pick P4: Work←[7,4,5]
• Pick P0: Work←[7,5,5]
• Pick P2: Work←[10,5,7]
All finish ⇒ Safe. One safe sequence: ⟨P1, P3, P4, P0, P2⟩.
Q11) Banker’s Algorithm — Request Validation
Same system as Q10. Process P1 requests [1,0,2].
Check 1) Request ≤ Need (P1 Need=[1,2,2])
Check 2) Request ≤ Available ([3,3,2])
Pretend to allocate:
• Available ← [2,3,0]
• Allocation(P1) ← [3,0,2]
• Need(P1) ← [0,2,0]
Run safety test:
• Pick P1 → Work [5,3,2]
• Pick P3 → Work [7,4,3]
• Pick P4 → Work [7,4,5]
• Pick P0 → Work [7,5,5]
• Pick P2 → Work [10,5,7]
All finish ⇒ Grant is SAFE .
Q12) Deadlock Detection — Wait-For Graph
Edges: P1→P2, P2→P3, P3→P1
There is a cycle (P1→P2→P3→P1) ⇒ Deadlock exists.
(If each resource type has a single instance, any cycle implies deadlock.)
Want a printable pack?
I can bundle these worked numericals + the earlier 300 MCQs into a neat PDF for quick revision, or add more practice sets (e.g., MLFQ,
effective access time with TLB, detailed Gantt with arrivals/preemption, more Banker’s). Just say the word and I’ll generate it.
You said:
I need bankers algorithm problem
ChatGPT said:
Thought for 40s
Awesome — here are Banker’s Algorithm problems with full, step-by-step solutions, plus a practice set at the end.
Problem 1 — Safety Check (classic 5×3)
Resources: A, B, C
Total in system: A=10, B=5, C=7
Allocation (Alloc)
P0: [0,1,0]
P1: [2,0,0]
P2: [3,0,2]
P3: [2,1,1]
P4: [0,0,2]
Max
P0: [7,5,3]
P1: [3,2,2]
P2: [9,0,2]
P3: [4,2,2]
P4: [5,3,3]
Step 1 — Available = Total − ΣAlloc
ΣAlloc = [7,2,5] → Available = [3,3,2]
Step 2 — Need = Max − Alloc
P0: [7,4,3]
P1: [1,2,2]
P2: [6,0,0]
P3: [2,1,1]
P4: [5,3,1]
Step 3 — Safety test (Work starts as Available = [3,3,2])
• Pick P1 (Need[1,2,2] ≤ Work[3,3,2]) → Finish; Work += Alloc(P1) = [3,3,2]+[2,0,0] = [5,3,2]
• Pick P3 (Need[2,1,1] ≤ [5,3,2]) → Work = [5,3,2]+[2,1,1] = [7,4,3]
• Pick P0 (Need[7,4,3] ≤ [7,4,3]) → Work = [7,4,3]+[0,1,0] = [7,5,3]
• Pick P2 (Need[6,0,0] ≤ [7,5,3]) → Work = [7,5,3]+[3,0,2] = [10,5,5]
• Pick P4 (Need[5,3,1] ≤ [10,5,5]) → Work = [10,5,5]+[0,0,2] = [10,5,7]
All processes can finish ⇒ SAFE.
One safe sequence: ⟨P1, P3, P0, P2, P4⟩.
Problem 2 — Request Evaluation (grant or deny?)
Use the same state as Problem 1.
Process P4 makes a request Req4 = [3,3,0].
Check 1 — Req ≤ Need(P4)? Need4=[5,3,1] ⇒ [3,3,0] ≤ [5,3,1]
Check 2 — Req ≤ Available? Available=[3,3,2] ⇒ [3,3,0] ≤ [3,3,2]
Pretend to allocate (temporary state):
Available′ = [3,3,2] − [3,3,0] = [0,0,2]
Alloc4′ = [0,0,2] + [3,3,0] = [3,3,2]
Need4′ = [5,3,1] − [3,3,0] = [2,0,1]
Safety test with Work = [0,0,2]:
• P1 Need [1,2,2] → B need 2 > 0
• P3 Need [2,1,1] → A need 2 > 0
• P0 Need [7,4,3]
• P2 Need [6,0,0] → A 6 > 0
• P4 Need [2,0,1] → A 2 > 0
No process can proceed ⇒ UNSAFE ⇒ DENY the request.
Problem 3 — Is this state safe or unsafe? (3×3)
Total: A=6, B=3, C=4
Allocation
P0: [1,1,0]
P1: [2,0,2]
P2: [0,2,1]
Max
P0: [3,2,2]
P1: [4,1,3]
P2: [3,3,3]
Available = Total − ΣAlloc
ΣAlloc = [3,3,3] → Available = [3,0,1]
Need = Max − Alloc
P0: [2,1,2]
P1: [2,1,1]
P2: [3,1,2]
Safety test (Work=[3,0,1]):
• P0 needs B=1 > 0
• P1 needs B=1 > 0
• P2 needs B=1 > 0
No starter process exists ⇒ UNSAFE state (not guaranteed deadlock, but not provably safe).
Problem 4 — Safe state and a “looks small” request (4×2)
Resources: R1, R2; Total: R1=7, R2=5
Allocation
P0: [1,2]
P1: [1,0]
P2: [1,3]
P3: [2,0]
Max
P0: [3,3]
P1: [2,2]
P2: [3,3]
P3: [4,2]
Available = Total − ΣAlloc
ΣAlloc = [5,5] → Available = [2,0]
Need
P0: [2,1]
P1: [1,2]
P2: [2,0]
P3: [2,2]
Safety test (Work=[2,0]):
• Pick P2 (Need [2,0]) → Work = [2,0]+Alloc[1,3] = [3,3]
• P0 (Need [2,1]) → Work = [3,3]+[1,2] = [4,5]
• P1 (Need [1,2]) → Work = [4,5]+[1,0] = [5,5]
• P3 (Need [2,2]) → finish.
SAFE, sequence ⟨P2,P0,P1,P3⟩.
Now a request: P1 asks Req1 = [1,0].
Check: Req ≤ Need([1,2]) and ≤ Available([2,0]) .
Allocate temporarily → Available′ = [1,0]; Alloc1′ = [2,0]; Need1′ = [0,2].
Safety (Work=[1,0]):
• P2 Need [2,0] → A need 2 > 1
• P0 Need [2,1]
• P3 Need [2,2]
• P1 Need [0,2] → B need 2 > 0
No progress ⇒ UNSAFE ⇒ DENY the request, even though it “looked small”.
Quick Checklist (what to write in the exam)
1. Compute Available and Need.
2. For a request: check Req ≤ Need and Req ≤ Available; then simulate and run the safety test.
3. For the safety test: repeatedly find a process with Need ≤ Work, mark it Finish, and add its Allocation to Work.
4. If all Finish → Safe (and request can be granted). If you get stuck → Unsafe (deny request).
Practice Set — You try (answers at the bottom)
Practice 1 (5×3, safety)
Total: A=9, B=3, C=6
Allocation:
P0 [0,1,0], P1 [2,0,0], P2 [3,0,3], P3 [2,1,1], P4 [0,0,1]
Max:
P0 [6,2,1], P1 [3,2,2], P2 [9,0,3], P3 [4,2,2], P4 [5,3,3]
Is the state safe? If yes, give one safe sequence.
Practice 2 (request check)
Use Practice 1’s state. P0 requests [0,1,1]. Grant or deny?
Practice 3 (3×3, safety)
Total: A=7, B=4, C=5
Allocation: P0 [1,1,1], P1 [2,0,2], P2 [1,2,0]
Max: P0 [3,2,2], P1 [4,1,3], P2 [3,3,2]
Safe or unsafe?
Practice 4 (request leads to safe)
Total: A=10, B=5, C=7
Allocation: P0 [0,2,0], P1 [2,0,0], P2 [3,0,2], P3 [1,1,1], P4 [0,0,2]
Max: P0 [3,3,2], P1 [3,2,2], P2 [7,1,2], P3 [4,2,2], P4 [5,3,3]
Available: compute it. If P3 requests [1,0,0], should it be granted?
Practice 5 (4×2, safety)
Total: R1=8, R2=6
Allocation: P0[2,1], P1[1,2], P2[2,2], P3[1,0]
Max: P0[3,3], P1[3,3], P2[4,3], P3[4,2]
Is the system safe? Give a safe sequence if it exists.
Answers (brief)
P1: Safe. One sequence: ⟨P1, P3, P0, P2, P4⟩.
P2: Deny (unsafe after pretend allocation).
P3: Unsafe.
P4: Available = Total − ΣAlloc = [10−(0+2+3+1+0), 5−(2+0+0+1+0), 7−(0+0+2+1+2)] = [4,2,2].
Req3=[1,0,0] ≤ Need3 and ≤ Available → simulate; safety holds (you’ll find a sequence), so Grant.
P5: Safe. One sequence: ⟨P3, P0, P1, P2⟩.