Exam Module Subscription Required
You need an active Exam Module Subscription to access this content. Subscribe now to unlock the exam materials and continue your preparation.
Previous Job Question: Page Fault and Thrasing in OS
Previous Job Question: Page Fault and Thrasing in OS
- ☆1Operating SystemPage Fault & ThrashingDefine Socket, Kernel, Process, Program, Multiprogramming, and Context Switching. Discuss the LRU and NRU Page Replacement Algorithms. Illustrate Preemptive Priority Scheduling.CB, AE(IT)/AME, 24 | AME/ANE/AE
Basic Definitions
- Socket: Endpoint for communication between two systems over a network (IP + Port).
- Kernel: Core part of OS that manages hardware, memory, and processes.
- Program: A set of instructions stored on disk.
- Process: A program in execution state.
- Multiprogramming: Multiple programs kept in memory and CPU switches among them to maximize utilization.
- Context Switching: Saving and loading process state when CPU switches from one process to another.
LRU (Least Recently Used) Page Replacement
- Replaces the page that was least recently used.
- Uses past usage to predict future behavior.
- Advantage: Good performance, low page fault rate.
- Disadvantage: Requires tracking usage → overhead.
NRU (Not Recently Used) Page Replacement
- Classifies pages based on Referenced (R) and Modified (M) bits.
- Selects a page from lowest priority class (not recently used).
- Advantage: Simple and efficient.
- Disadvantage: Less accurate than LRU.
Preemptive Priority Scheduling
- CPU is assigned to process with highest priority.
- If a new process with higher priority arrives, current process is preempted.
Example:
- P1 (Priority 2) is running
- P2 (Priority 1, higher) arrives → P1 is stopped
- P2 gets CPU immediately
সংজ্ঞা
- Socket: network-এ communication-এর endpoint (IP + Port)।
- Kernel: OS-এর মূল অংশ যা hardware, memory, process নিয়ন্ত্রণ করে।
- Program: disk-এ থাকা instruction-এর সেট।
- Process: চলমান program (execution অবস্থায়)।
- Multiprogramming: একাধিক program memory-তে রেখে CPU alternately execute করে।
- Context Switching: এক process থেকে অন্য process-এ যাওয়ার সময় state save/load করা।
LRU Page Replacement
- যে page সবচেয়ে দীর্ঘ সময় ব্যবহার হয়নি সেটি replace করা হয়।
- সুবিধা: ভালো performance দেয়।
- অসুবিধা: usage track করতে overhead লাগে।
NRU Page Replacement
- page-কে Referenced (R) এবং Modified (M) bit দিয়ে classify করা হয়।
- কম ব্যবহৃত page replace করা হয়।
- সুবিধা: সহজ algorithm।
- অসুবিধা: LRU-এর মতো accurate নয়।
Preemptive Priority Scheduling
- সবচেয়ে উচ্চ priority process CPU পায়।
- নতুন উচ্চ priority process এলে চলমান process stop হয়ে যায়।
উদাহরণ:
- P1 (Priority 2) চলছে
- P2 (Priority 1, বেশি) এলে → P1 বন্ধ
- P2 CPU পায়
- ☆2Operating SystemPage Fault & ThrashingExplain the concept of thrashing in an operating system, describing how it occurs in a demand-paged virtual memory system and how it impacts CPU utilization and overall system performance. (10 Marks)Combined Bank, SO-IT, 25 | Senior Officer (IT)
Thrashing in Operating System
Thrashing is a condition in an operating system where the system spends most of its time swapping pages in and out of memory instead of executing actual processes. It mainly occurs in a demand-paged virtual memory system when there are not enough frames to support the working sets of active processes.How Thrashing Occurs in Demand Paging
In demand paging, pages are loaded into memory only when they are needed. If too many processes are running and physical memory is insufficient, frequent page faults occur. The OS continuously replaces pages, but the required pages are again needed immediately, causing excessive paging activity. This situation leads to thrashing.Impact on CPU Utilization
During thrashing, CPU utilization becomes very low because the CPU waits for disk I/O operations caused by page faults. Even though many processes are active, the CPU remains mostly idle.Impact on System Performance
Overall system performance degrades severely. Response time increases, throughput decreases, and the system becomes slow and inefficient. To handle thrashing, the OS may reduce the degree of multiprogramming or use working set and page fault frequency control techniques.Operating System এ Thrashing
Thrashing হলো একটি অবস্থা যেখানে operating system অধিকাংশ সময় memory থেকে page আনা-নেওয়ায় ব্যয় করে, process execute করার পরিবর্তে। এটি মূলত demand-paged virtual memory system এ ঘটে, যখন active process গুলোর জন্য যথেষ্ট frame থাকে না।Demand Paging এ Thrashing কীভাবে ঘটে
Demand paging এ page তখনই memory তে আনা হয় যখন সেটি দরকার হয়। যদি একসাথে অনেক process চালানো হয় এবং physical memory কম থাকে, তাহলে বারবার page fault ঘটে। OS এক page remove করে আরেকটা আনে, কিন্তু আগের page আবার দরকার পড়ে। এতে অতিরিক্ত paging শুরু হয়, যা thrashing সৃষ্টি করে।CPU Utilization এর উপর প্রভাব
Thrashing এর সময় CPU utilization খুব কমে যায়, কারণ CPU বারবার disk I/O এর জন্য অপেক্ষা করে। অনেক process থাকা সত্ত্বেও CPU প্রায় idle থাকে।System Performance এর উপর প্রভাব
System performance অনেক খারাপ হয়ে যায়। Response time বেড়ে যায়, throughput কমে যায় এবং system ধীরগতির হয়ে পড়ে। Thrashing কমাতে OS degree of multiprogramming কমাতে পারে অথবা working set ও page fault frequency technique ব্যবহার করতে পারে। - ☆3Operating SystemPage Fault & ThrashingConsider page reference string 1, 3, 0, 3, 5, 6, 3 with 3 page frames.Find the number of page faults.CB, AP, 23 | Assistant ProgrammerGiven:
- Page reference string: 1, 3, 0, 3, 5, 6, 3
- Number of page frames: 3
Explanation:- 1 causes a page fault as it's not in memory, so it's loaded into frame 1.
- 3 causes a page fault and is loaded into frame 2.
- 0 causes a page fault and is loaded into frame 3. All three frames are now full.
- 3 is already in memory, so no page fault occurs (Hit).
- 5 causes a page fault and replaces the oldest page in memory, which is 1.
- 6 causes a page fault and replaces the oldest page in memory, which is 3.
- 3 causes a page fault and replaces the oldest page in memory, which is 0.
- 6 Page Faults

Explanation: