Basic Introduction to Operating system, Types of OS and its function
Operating System (OS)
An Operating System is a System Software that acts as an interface between the user and computer hardware. It works as a communication medium that allows users to interact with hardware components.
It is also called a Resource Manager because it manages both hardware and software resources such as:
• Memory
• Files
• Disk
• Input-Output Devices
• CPU Scheduling
The OS ensures that these resources are used efficiently and properly.
Goals / Need of Operating System:
• Provides a user-friendly interface
• Manages hardware and software resources
• Improves system performance and optimization
• Ensures system security and control
• Uses hardware resources efficiently
Parts of Operating System
An Operating System has two main parts:
1) Kernel:
The Kernel is the core component of the OS. It directly interacts with hardware and manages system resources like CPU, memory, and devices.
2) Shell:
The Shell acts as a Command Interpreter. It takes user commands, interprets them, and communicates with the Kernel to perform required tasks. It is responsible for user interaction.
Interaction Flow:
User ↔ Shell ↔ Kernel ↔ Hardware
• The user interacts with the Shell through commands or applications.
• The Shell communicates instructions to the Kernel.
• The Kernel interacts with hardware to execute tasks.
Operating System (OS)
Operating System হলো একটি System Software যা user এবং computer hardware-এর মধ্যে interface হিসেবে কাজ করে। এটি communication মাধ্যম হিসেবে কাজ করে যাতে user hardware-এর সাথে যোগাযোগ করতে পারে।
এটিকে Resource Manager ও বলা হয়, কারণ এটি hardware ও software resource পরিচালনা করে, যেমন:
• Memory
• Files
• Disk
• Input-Output Device
• CPU Scheduling
OS এই resource গুলো দক্ষভাবে ব্যবহারের নিশ্চয়তা দেয়।
Operating System-এর লক্ষ্য / প্রয়োজনীয়তা:
• User-এর জন্য সহজ interface প্রদান করা
• Hardware ও software resource পরিচালনা করা
• System-এর performance ও optimization বৃদ্ধি করা
• System security ও control নিশ্চিত করা
• Hardware resource দক্ষভাবে ব্যবহার করা
Operating System-এর অংশ
Operating System-এর দুটি প্রধান অংশ রয়েছে:
1) Kernel:
Kernel হলো OS-এর মূল অংশ। এটি সরাসরি hardware-এর সাথে কাজ করে এবং CPU, memory ও device management পরিচালনা করে।
2) Shell:
Shell একটি Command Interpreter হিসেবে কাজ করে। এটি user-এর command গ্রহণ করে, ব্যাখ্যা করে এবং Kernel-কে প্রয়োজনীয় কাজ সম্পাদনের নির্দেশ দেয়। এটি user interaction পরিচালনা করে।
Interaction Flow:
User ↔ Shell ↔ Kernel ↔ Hardware
• User command বা application-এর মাধ্যমে Shell-এর সাথে যোগাযোগ করে।
• Shell নির্দেশ Kernel-এ পাঠায়।
• Kernel hardware-এর সাথে কাজ করে নির্দিষ্ট কাজ সম্পন্ন করে।
🎥 Video Solution: What is Operating System? Needs/Goals of OS, Part of OS (Shell & kernel)
Operating System (OS) is system software that controls and manages the hardware and software of a computer.
It works as a bridge between the user and the computer, helping the computer run smoothly and properly.
Different types of Operating System are designed for different purposes. Some OS can perform only one task at a time, while others can handle many users or real-time tasks at the same time.
In short, an Operating System makes the computer easy and efficient to use.
Operating System (OS) হলো একটি System Software যা কম্পিউটারের Hardware ও Software নিয়ন্ত্রণ ও পরিচালনা করে।
এটি User এবং Computer-এর মধ্যে Bridge হিসেবে কাজ করে এবং কম্পিউটারকে সঠিকভাবে ও মসৃণভাবে পরিচালনা করতে সহায়তা করে।
বিভিন্ন ধরনের Operating System বিভিন্ন প্রয়োজন পূরণ করে। কিছু OS এক সময়ে একটি কাজ করে, আবার কিছু OS একাধিক User বা Real-time Task একসাথে পরিচালনা করতে পারে।
সারসংক্ষেপে, Operating System কম্পিউটারকে সহজ ও কার্যকরভাবে ব্যবহার করতে সাহায্য করে।
Different Types of Operating System:
1. Batch OS
2. Multi-programming Os
3. Multitasking OS
4. Multiprocessing OS
5. Time Sharing OS
6. Distributed OS
7. Network OS
8. Mobile OS
[urcr_restrict]
Batch Operating System is a type of Operating System designed to process a large number of similar jobs efficiently. In this system, users do not interact directly with the computer. Jobs are collected, grouped into batches by an operator, and executed automatically one after another.
It executes a group of similar jobs automatically in batches without user interaction.
Advantages of Batch Operating System:
1. Minimal Idle Time: Jobs are processed continuously without human intervention, reducing idle time.
2. Handling Repetitive Tasks: Suitable for large and repetitive tasks such as payroll and billing systems.
3. Improved Throughput: Can process a high volume of jobs, increasing overall system throughput.
Disadvantages of Batch Operating System:
1. Inefficient CPU Utilization: CPU remains idle when waiting for I/O operations.
2. Increased Response Time: Output takes longer because jobs are processed sequentially.
3. Lack of Real-Time Feedback: Users cannot interact with the system during execution.
In conclusion, Batch Operating System is suitable for large repetitive processing tasks but not ideal for interactive or real-time applications.
Batch Operating System হলো এমন একটি Operating System যা একই ধরনের বিপুল সংখ্যক Job দক্ষতার সাথে Processing করার জন্য তৈরি। এখানে User সরাসরি Computer-এর সাথে Interaction করতে পারে না। Job গুলো Operator সংগ্রহ করে Batch আকারে সাজিয়ে একটির পর একটি স্বয়ংক্রিয়ভাবে Execute করে।
এটি User Interaction ছাড়া একই ধরনের Job গুলোকে Batch আকারে স্বয়ংক্রিয়ভাবে Execute করে।
Batch Operating System-এর সুবিধাসমূহ:
১. Minimal Idle Time: Human Intervention ছাড়া ধারাবাহিকভাবে Job Processing হওয়ায় Idle Time কম হয়।
২. Handling Repetitive Tasks: Payroll, Billing-এর মতো বড় ও Repetitive Task পরিচালনার জন্য উপযোগী।
৩. Improved Throughput: একসাথে অনেক Job Processing করে System Throughput বৃদ্ধি করে।
Batch Operating System-এর অসুবিধাসমূহ:
১. Inefficient CPU Utilization: I/O Operation-এর সময় CPU Idle থাকে।
২. Increased Response Time: ধারাবাহিকভাবে Job Execute হওয়ায় Output পেতে বেশি সময় লাগে।
৩. Lack of Real-Time Feedback: Execution চলাকালীন User Real-time Interaction করতে পারে না।
সারসংক্ষেপে, Batch Operating System বড় ও Repetitive Processing কাজের জন্য উপযুক্ত হলেও Interactive বা Real-time Application-এর জন্য উপযোগী নয়।
[/urcr_restrict]
[urcr_restrict]
Multi-Programming Operating System is a type of Operating System where multiple programs are kept in memory at the same time. The CPU switches from one program to another so that it remains busy and overall system performance improves.It runs multiple programs in memory at the same time to maximize CPU usage.
Advantages of Multi-Programming Operating System:
1. Better CPU Utilization: CPU switches to another job during I/O wait and stays busy.
2. Improved Throughput: Multiple jobs run concurrently, increasing work done per unit time.
3. Efficient Resource Use: CPU, memory, and I/O devices are shared effectively among processes.
Disadvantages of Multi-Programming Operating System:
1. Complex Design: Requires advanced memory management and CPU scheduling.
2. Security Issues: More programs in memory increase the risk of unauthorized access.
3. High Memory Requirement: Requires more memory.
In conclusion, Multi-Programming Operating System improves CPU utilization and performance but requires complex management and more memory.
Multi-Programming Operating System হলো এমন একটি Operating System যেখানে একাধিক Program একই সময়ে Memory-তে সংরক্ষিত থাকে। CPU একটি Program থেকে অন্য Program-এ Switch করে, ফলে CPU Busy থাকে এবং System Performance বৃদ্ধি পায়।
এটি একই সময়ে একাধিক Program Memory-তে চালিয়ে CPU Usage সর্বোচ্চ করে।
Multi-Programming Operating System-এর সুবিধাসমূহ:
১. Better CPU Utilization: একটি Job I/O অপেক্ষায় থাকলে CPU অন্য Job-এ Switch করে Busy থাকে।
২. Improved Throughput: একাধিক Job একসাথে Concurrently চলায় প্রতি একক সময়ে কাজের পরিমাণ বৃদ্ধি পায়।
৩. Efficient Resource Use: CPU, Memory এবং I/O Device কার্যকরভাবে Process-এর মধ্যে ভাগ করা হয়।
Multi-Programming Operating System-এর অসুবিধাসমূহ:
১. Complex Design: উন্নত Memory Management ও CPU Scheduling প্রয়োজন।
২. Security Issues: বেশি Program Memory-তে থাকলে Unauthorized Access-এর ঝুঁকি বাড়ে।
৩. High Memory Requirement: বেশি Memory প্রয়োজন।
সারসংক্ষেপে, Multi-Programming Operating System CPU Utilization ও System Performance বৃদ্ধি করে, তবে জটিল ব্যবস্থাপনা ও বেশি Memory প্রয়োজন।
[/urcr_restrict]
[urcr_restrict]
Multi-Processing Operating System is a type of Operating System in which more than one CPU is used to execute processes. It improves the throughput and overall performance of the system.
It uses two or more CPUs simultaneously to increase speed and reliability.
Advantages of Multi-Processing Operating System:
1. Faster Processing: Multiple CPUs work at the same time, increasing system speed.
2. High Reliability: If one processor fails, other processors continue working (fault tolerance).
3. Supports Heavy Tasks: Suitable for computation-intensive applications such as scientific and industrial tasks.
Disadvantages of Multi-Processing Operating System:
1. High Cost: Multiple processors and complex hardware increase the system cost.
2. Complex Design: Requires advanced OS support for communication and task distribution.
3. Not Always Efficient: Poor task distribution may cause idle processors and waste resources.
Examples:
• UNIX
• Linux (Ubuntu, Red Hat, Debian)
• macOS
In conclusion, Multi-Processing Operating System increases speed and reliability but requires high cost and complex management.
Multi-Processing Operating System হলো এমন একটি Operating System যেখানে একাধিক CPU ব্যবহার করে Process Execute করা হয়। এটি System-এর Throughput ও সামগ্রিক Performance বৃদ্ধি করে।
এটি একই সময়ে দুই বা ততোধিক CPU ব্যবহার করে Speed ও Reliability বৃদ্ধি করে।
Multi-Processing Operating System-এর সুবিধাসমূহ:
১. Faster Processing: একাধিক CPU একসাথে কাজ করে System Speed বৃদ্ধি করে।
২. High Reliability: একটি Processor ব্যর্থ হলেও অন্য Processor কাজ চালিয়ে যেতে পারে (Fault Tolerance)।
৩. Supports Heavy Tasks: Scientific বা Industrial-এর মতো Computation-intensive Application-এর জন্য উপযোগী।
Multi-Processing Operating System-এর অসুবিধাসমূহ:
১. High Cost: একাধিক Processor ও Complex Hardware ব্যবহারের কারণে System Cost বেশি।
২. Complex Design: Communication ও Task Distribution-এর জন্য উন্নত OS Support প্রয়োজন।
৩. Not Always Efficient: সঠিক Task Distribution না হলে Processor Idle থাকতে পারে এবং Resource অপচয় হয়।
উদাহরণ:
• UNIX
• Linux (Ubuntu, Red Hat, Debian)
• macOS
সারসংক্ষেপে, Multi-Processing Operating System Speed ও Reliability বৃদ্ধি করে, তবে এর Cost বেশি এবং ব্যবস্থাপনা জটিল।
[/urcr_restrict]

Multi-Tasking Operating System is a type of multiprogramming system where multiple tasks are executed by the CPU in a round-robin manner. Each task is given a fixed time slice called a Time Quantum.
When the time quantum expires, the Operating System switches to the next task. This rapid switching allows multiple tasks—whether from a single user or multiple users—to run smoothly on the same system.
It allows multiple tasks to run by giving each a small time slice for shared and smooth system use.
Advantages of Multi-Tasking Operating System:
1. Equal CPU Access: Each task gets a fair share of CPU time.
2. Reduced Software Duplication: Multiple users can use the same software without separate copies.
3. Low CPU Idle Time: Efficient scheduling keeps the CPU busy.
Disadvantages of Multi-Tasking Operating System:
1. Lower Reliability: System failure can affect all running tasks.
2. Security Concerns: Multiple users increase risks to data integrity and privacy.
3. Communication Issues: Data sharing between users may cause conflicts.
Examples:
• IBM VM/CMS
• TSO (Time Sharing Option)
• Windows Terminal Services
Multi-Tasking Operating System হলো এমন একটি Multiprogramming System যেখানে একাধিক Task Round-Robin পদ্ধতিতে Execute হয়। প্রতিটি Task একটি নির্দিষ্ট সময় পায়, যাকে Time Quantum বলা হয়।
Time Quantum শেষ হলে Operating System পরবর্তী Task-এ Switch করে। দ্রুত Switching-এর মাধ্যমে একই System-এ একাধিক User বা একাধিক Task একসাথে Smoothভাবে চলতে পারে।
এটি প্রতিটি Task-কে ছোট সময় ভাগ দিয়ে একাধিক Task চালানোর সুযোগ দেয়।
Multi-Tasking Operating System-এর সুবিধাসমূহ:
১. Equal CPU Access: প্রতিটি Task সমানভাবে CPU Time পায়।
২. Reduced Software Duplication: একাধিক User একই Software ব্যবহার করতে পারে।
৩. Low CPU Idle Time: কার্যকর Scheduling-এর কারণে CPU Idle কম থাকে।
Multi-Tasking Operating System-এর অসুবিধাসমূহ:
১. Lower Reliability: System Failure হলে সকল Task প্রভাবিত হতে পারে।
২. Security Concerns: একাধিক User থাকার কারণে Data Integrity ও Privacy ঝুঁকি থাকে।
৩. Communication Issues: Data Sharing-এর কারণে Conflict হতে পারে।
উদাহরণ:
• IBM VM/CMS
• TSO (Time Sharing Option)
• Windows Terminal Services
[urcr_restrict]
Time-Sharing Operating System is a type of Operating System that allows multiple users to use a computer system at the same time from different terminals. The processor time is divided and shared among users. This technique is also known as multitasking.
It is a logical extension of multiprogramming where the main objective is to minimize response time, unlike Multiprogrammed Batch Systems which aim to maximize CPU utilization.
The CPU switches between multiple jobs very frequently. Each user gets a small unit of CPU time called a Time Quantum. Because of this fast switching, users receive responses within a few seconds.
The Operating System uses CPU Scheduling and Multiprogramming to give each user a small portion of CPU time. Many batch systems were later modified into time-sharing systems.
Advantages of Time-Sharing Operating System:
1. Quick Response: Provides fast response to users.
2. Avoids Software Duplication: Multiple users can share the same software.
3. Reduces CPU Idle Time: CPU remains busy by switching between tasks.
Disadvantages of Time-Sharing Operating System:
1. Reliability Problem: System failure can affect all users.
2. Security Issues: Risk to user programs and data integrity.
3. Data Communication Problem: Requires proper communication management.
In conclusion, Time-Sharing Operating System provides fast response and better resource sharing but faces security and reliability challenges.
Time-Sharing Operating System হলো এমন একটি Operating System যেখানে একাধিক User বিভিন্ন Terminal থেকে একই সময়ে একটি Computer System ব্যবহার করতে পারে। Processor-এর সময় ভাগ করে User-দের মধ্যে বিতরণ করা হয়। এই পদ্ধতিকে Multitaskingও বলা হয়।
এটি Multiprogramming-এর একটি Logical Extension। এখানে মূল লক্ষ্য হলো Response Time কমানো, যেখানে Multiprogrammed Batch System-এর লক্ষ্য ছিল CPU Utilization বৃদ্ধি করা।
CPU খুব দ্রুত এক Job থেকে অন্য Job-এ Switch করে। প্রত্যেক User একটি নির্দিষ্ট সময় পায়, যাকে Time Quantum বলা হয়। দ্রুত Switching-এর কারণে User কয়েক সেকেন্ডের মধ্যেই Response পায়।
Operating System CPU Scheduling এবং Multiprogramming ব্যবহার করে প্রত্যেক User-কে অল্প সময়ের CPU ভাগ দেয়। অনেক Batch System পরবর্তীতে Time-Sharing System-এ রূপান্তর করা হয়েছে।
Time-Sharing Operating System-এর সুবিধাসমূহ:
১. Quick Response: দ্রুত Response প্রদান করে।
২. Avoids Software Duplication: একাধিক User একই Software শেয়ার করতে পারে।
৩. Reduces CPU Idle Time: Task Switching-এর মাধ্যমে CPU Idle কম থাকে।
Time-Sharing Operating System-এর অসুবিধাসমূহ:
১. Reliability Problem: System Failure হলে সকল User প্রভাবিত হতে পারে।
২. Security Issues: User Program ও Data Integrity ঝুঁকিতে পড়তে পারে।
৩. Data Communication Problem: সঠিক Communication Management প্রয়োজন।
সারসংক্ষেপে, Time-Sharing Operating System দ্রুত Response ও উন্নত Resource Sharing নিশ্চিত করে, তবে Security ও Reliability সংক্রান্ত কিছু চ্যালেঞ্জ রয়েছে।
[/urcr_restrict]
User Space & Kernel Space, Kernel : Micro Kernel, Macro Kernel
[urcr_restrict]
Kernel
Kernel is the core component (heart) of an Operating System. It is responsible for managing all major functions of the OS, including CPU management, memory management, device management, and process control. It acts as a communication bridge between user applications and hardware.
When the operating system boots, the kernel is the first component loaded into memory and it remains active until the system is shut down.
User Space and Kernel Space
When an application or program runs, its execution happens in two separate areas:
1) User Space:
This is the area where user-level applications run, such as Browser, Media Player, Text Editor, etc. Programs in user space cannot directly access hardware; they must request services from the kernel.
2) Kernel Space:
This is the protected area where the kernel operates. It has full access to system resources such as CPU, Memory, Network, and Hardware Devices. All critical system operations are performed in kernel space.
Thus, the separation between user space and kernel space ensures system stability and security.
Kernel
Kernel হলো Operating System-এর মূল অংশ (heart)। এটি OS-এর সকল গুরুত্বপূর্ণ কাজ পরিচালনা করে, যেমন CPU management, memory management, device management এবং process control। এটি user application এবং hardware-এর মধ্যে communication bridge হিসেবে কাজ করে।
System চালু হলে kernel সর্বপ্রথম memory-তে load হয় এবং system shutdown না হওয়া পর্যন্ত সক্রিয় থাকে।
User Space এবং Kernel Space
যখন কোনো application বা program চলে, তখন তার কার্যপ্রক্রিয়া দুইটি আলাদা অংশে সম্পন্ন হয়:
1) User Space:
এখানে user-level application চলে, যেমন Browser, Media Player, Text Editor ইত্যাদি। User space-এর program সরাসরি hardware access করতে পারে না; kernel-এর মাধ্যমে service নিতে হয়।
2) Kernel Space:
এটি একটি সুরক্ষিত এলাকা যেখানে kernel কাজ করে। এখানে CPU, Memory, Network এবং Hardware Device-এর পূর্ণ নিয়ন্ত্রণ থাকে। সকল গুরুত্বপূর্ণ system operation kernel space-এ সম্পন্ন হয়।
এইভাবে user space এবং kernel space-এর পৃথকীকরণ system-এর স্থিতিশীলতা ও নিরাপত্তা নিশ্চিত করে।
[/urcr_restrict]
Monolithic Kernel
The Monolithic Kernel is the earliest type of kernel architecture used in operating systems. In this architecture, all operating system services are combined and executed in the same memory area called Kernel Space.

In this structure, the User Space contains only user applications. All major components such as Virtual File System, System Call Interface, Inter-Process Communication (IPC), File System, Scheduler, Device Drivers, and other services are placed together inside the Kernel Space.
Working Principle
Since all services are integrated into one large module, the kernel becomes large in size but performs faster.
• Larger in size – because all services are included inside Kernel Space.
• Faster execution – because there is no need for switching between spaces, which reduces overhead.
Problems with Monolithic Kernel
• Low stability – If any single service crashes, the entire operating system crashes.
• Difficult maintenance and debugging – The kernel becomes very large and complex, making bug detection difficult.
• Adding new services requires modifying and recompiling the whole kernel.
Advantages
• High speed
• Good performance
Disadvantages
• Less stable
• Complex and hard to maintain
Monolithic Kernel
Monolithic Kernel হলো Operating System-এর প্রাচীনতম kernel architecture। এই পদ্ধতিতে সব operating system service একই memory area অর্থাৎ Kernel Space-এ একসাথে কাজ করে।

এই গঠনে User Space-এ শুধুমাত্র user application থাকে। আর Virtual File System, System Call Interface, Inter-Process Communication (IPC), File System, Scheduler, Device Driver এবং অন্যান্য service সব Kernel Space-এর ভেতরে অবস্থান করে।
কার্যপ্রণালী (Working Principle)
সব service একত্রে একটি বড় module-এ থাকায় kernel আকারে বড় হয় কিন্তু execution দ্রুত হয়।
• আকারে বড় – কারণ সব service Kernel Space-এ থাকে।
• দ্রুত execution – কারণ space পরিবর্তন বা switching প্রয়োজন হয় না।
Monolithic Kernel-এর সমস্যা
• স্থিতিশীলতা কম – একটি service crash করলে পুরো Operating System crash করে।
• Maintenance ও debugging কঠিন – kernel বড় ও জটিল হওয়ায় bug খুঁজে বের করা কঠিন।
• নতুন service যোগ করতে পুরো kernel modify ও recompile করতে হয়।
সুবিধা
• উচ্চ গতি
• ভালো performance
অসুবিধা
• কম স্থিতিশীল
• জটিল ও রক্ষণাবেক্ষণ কঠিন
[urcr_restrict]
The Microkernel is a modern kernel architecture that follows a modular design approach. Unlike the Monolithic Kernel, only essential services run in the Kernel Space, while other services run in the User Space.

Components in Kernel Space
Only core services remain inside the kernel:
• Memory Management
• Process Scheduling
• Inter-Process Communication (IPC)
All other services such as File System, Device Drivers, Networking, and system services operate in User Space.
Working Principle
Since only essential services are kept in Kernel Space:
• Smaller in size – because limited components are inside the kernel.
• Modular design – services are separate and independent.
• Easier debugging and maintenance – new services can be added without modifying the entire kernel.
If a user-space service fails, the operating system continues running without crashing. This structure improves system security and stability because faults in User Space cannot directly affect the kernel.
Advantages
• Stable
• Secure
• Easy to maintain
• Fault-tolerant (failure of one service does not crash OS)
Disadvantages
• Slower execution compared to Monolithic Kernel due to communication overhead between User Space and Kernel Space
Microkernel
Microkernel হলো একটি আধুনিক kernel architecture যা modular design অনুসরণ করে। Monolithic Kernel-এর বিপরীতে, এখানে শুধুমাত্র প্রয়োজনীয় service Kernel Space-এ থাকে এবং অন্যান্য service User Space-এ পরিচালিত হয়।

Kernel Space-এ থাকা Component
শুধুমাত্র মূল service গুলো kernel-এর অংশ:
• Memory Management
• Process Scheduling
• Inter-Process Communication (IPC)
File System, Device Driver, Networking এবং অন্যান্য system service User Space-এ কাজ করে।
কার্যপ্রণালী (Working Principle)
Kernel Space-এ সীমিত service রাখার ফলে:
• আকারে ছোট – কারণ কম component kernel-এর ভেতরে থাকে।
• Modular design – প্রতিটি service আলাদা ও স্বাধীন।
• Debugging ও maintenance সহজ – নতুন service যোগ করতে পুরো kernel পরিবর্তন করতে হয় না।
যদি কোনো User Space service ব্যর্থ হয়, তবুও Operating System crash করে না। এই নকশা বেশি security ও stability প্রদান করে, কারণ User Space-এর ত্রুটি সরাসরি kernel-কে প্রভাবিত করতে পারে না।
সুবিধা
• স্থিতিশীল
• নিরাপদ
• রক্ষণাবেক্ষণ সহজ
• Fault-tolerant (একটি service ব্যর্থ হলেও OS crash করে না)
অসুবিধা
• Monolithic Kernel-এর তুলনায় execution ধীর, কারণ User Space ও Kernel Space-এর মধ্যে communication overhead থাকে
[/urcr_restrict]
Process and Thread
Process is a program that is currently under execution. It is an active entity of a program. When a program is loaded into memory and executed by the CPU, it becomes a process.
A process is more than just program code. It includes the Program Counter, Registers, Process Stack, and other resources. The information about a process is stored in a data structure called PCB (Process Control Block).
A process can create another process known as a Child Process, while the creating process is called the Parent Process. Each process has its own memory space and does not share memory with other processes.
Advantages of Process:
1. Independent Execution: Works independently in separate memory, improving security.
2. Efficient Resource Allocation: CPU and memory resources are managed efficiently.
3. Task Prioritization: Processes can be prioritized for better management.
Disadvantages of Process:
1. Context Switching Overhead: Frequent context switching may reduce system speed.
2. Deadlock Risk: Improper resource handling may cause deadlock.
3. High Memory Usage: Too many processes increase memory usage and management overhead.
In conclusion, a Process is an active program with its own memory and resources, managed by the Operating System for efficient execution.
Process হলো এমন একটি Program যা বর্তমানে Execution অবস্থায় আছে। যখন একটি Program Memory-তে লোড হয়ে CPU দ্বারা Execute হয়, তখন সেটি Process এ পরিণত হয়।
Process শুধু Program Code নয়; এতে Program Counter, Registers, Process Stack এবং অন্যান্য Resource অন্তর্ভুক্ত থাকে। একটি Process-এর সকল তথ্য PCB (Process Control Block)-এ সংরক্ষিত থাকে।
একটি Process অন্য Process তৈরি করতে পারে, যাকে Child Process বলা হয় এবং যে Process তৈরি করে তাকে Parent Process বলা হয়। প্রতিটি Process-এর নিজস্ব Memory Space থাকে এবং এটি অন্য Process-এর সাথে Memory শেয়ার করে না।
Process-এর সুবিধাসমূহ:
১. Independent Execution: আলাদা Memory-তে কাজ করে, ফলে Security বৃদ্ধি পায়।
২. Efficient Resource Allocation: CPU ও Memory কার্যকরভাবে ব্যবস্থাপনা করা যায়।
৩. Task Prioritization: প্রয়োজন অনুযায়ী Process-কে Priority দেওয়া যায়।
Process-এর অসুবিধাসমূহ:
১. Context Switching Overhead: ঘন ঘন Context Switching হলে System Speed কমতে পারে।
২. Deadlock Risk: ভুল Resource Management-এর কারণে Deadlock হতে পারে।
৩. High Memory Usage: বেশি Process হলে বেশি Memory প্রয়োজন হয় এবং Management জটিল হয়।
সারসংক্ষেপে, Process হলো একটি Active Program যা নিজস্ব Memory ও Resource ব্যবহার করে Operating System-এর নিয়ন্ত্রণে কার্য সম্পাদন করে।

Process State Diagram shows the different states of a process and how it moves from one state to another during execution in an Operating System.
Main States of a Process:
1. New: A process is created (job is entered into the system) but not yet ready to run.
2. Ready: The process is in main memory and waiting for CPU. It is ready to execute.
3. Running: The process is currently executing on the CPU.
4. Waiting (Blocked): The process cannot continue until an I/O operation or an event completes.
5. Terminated: The process finishes execution and exits from the system.
Process State Diagram দেখায় একটি Process কী কী State-এ থাকে এবং Execution চলাকালীন এক State থেকে আরেক State-এ কীভাবে Move করে।
Process-এর প্রধান States:
১. New: নতুন Process তৈরি হয়, কিন্তু এখনো CPU-তে চলার জন্য Ready নয়।
২. Ready: Process Main Memory-তে আছে এবং CPU পাওয়ার জন্য Ready Queue-তে অপেক্ষা করে।
৩. Running: Process এখন CPU-তে Execute হচ্ছে।
৪. Waiting (Blocked): I/O বা কোনো Event শেষ না হওয়া পর্যন্ত Process চলতে পারে না।
৫. Terminated: কাজ শেষ হলে Process Exit করে এবং শেষ হয়ে যায়।
[urcr_restrict]
Thread is called a lightweight process because it shares some features of a process but is smaller and faster. Every thread belongs to a specific process and cannot exist independently.
A thread has its own Registers, Program Counter, and Stack, but it shares Memory, Data Segment, Code Segment, and other resources with other threads of the same process.
Unlike processes, threads do not isolate memory. Therefore, an error in one thread may affect other threads. A thread takes less time to create and terminate compared to a process.
Example:
In a mobile banking app, multiple threads work together. One thread loads account balance, another handles user input, and another loads images. Because threads run simultaneously, the app remains smooth and responsive.
Advantages of Thread:
1. Improved Performance: Tasks run in parallel, especially useful for I/O operations.
2. Fast Creation and Termination: Threads are faster to create and destroy than processes.
3. Multitasking Support: Allows applications to perform multiple tasks at the same time.
Disadvantages of Thread:
1. Shared Memory Risk: Error in one thread can affect others.
2. Resource Conflict: Shared resources may cause conflicts and unexpected behavior.
3. Performance Issue: Too many threads may reduce performance and consume more memory.
In conclusion, a Thread is a lightweight execution unit within a process that improves performance but requires proper synchronization and management.
Thread কে Lightweight Process বলা হয়, কারণ এটি Process-এর কিছু বৈশিষ্ট্য শেয়ার করলেও আকারে ছোট ও দ্রুত। প্রতিটি Thread একটি নির্দিষ্ট Process-এর অংশ এবং আলাদাভাবে থাকতে পারে না।
Thread-এর নিজস্ব Registers, Program Counter এবং Stack থাকে, তবে একই Process-এর অন্যান্য Thread-এর সাথে Memory, Data Segment, Code Segment ও Resource শেয়ার করে।
Process-এর মতো Thread Memory আলাদা করে না (Isolation নেই)। তাই একটি Thread-এ Error হলে অন্য Thread-এ প্রভাব ফেলতে পারে। Process-এর তুলনায় Thread তৈরি ও Terminate করতে কম সময় লাগে।
উদাহরণ:
Mobile Banking App-এ একাধিক Thread একসাথে কাজ করে। একটি Thread Balance লোড করে, অন্যটি User Input পরিচালনা করে, আরেকটি Image লোড করে। ফলে App Smooth ও Responsive থাকে।
Thread-এর সুবিধাসমূহ:
১. Improved Performance: বিশেষ করে I/O Operation-এ Parallelভাবে কাজ করে Performance বাড়ায়।
২. Fast Creation and Termination: Process-এর তুলনায় দ্রুত তৈরি ও Terminate করা যায়।
৩. Multitasking Support: একই সময়ে একাধিক Task সম্পাদন করা যায়।
Thread-এর অসুবিধাসমূহ:
১. Shared Memory Risk: একটি Thread-এর Error অন্য Thread-এ প্রভাব ফেলতে পারে।
২. Resource Conflict: Shared Resource-এর কারণে Conflict হতে পারে।
৩. Performance Issue: অতিরিক্ত Thread হলে Performance কমতে পারে এবং বেশি Memory ব্যবহার হয়।
সারসংক্ষেপে, Thread হলো একটি Lightweight Execution Unit যা Process-এর ভেতরে কাজ করে Performance বৃদ্ধি করে, তবে সঠিক Synchronization প্রয়োজন।
[/urcr_restrict]


[urcr_restrict]
Multithreading is a technique in which multiple threads are created within a single process and executed concurrently. It allows a program to perform multiple tasks at the same time using shared resources.In multithreading, threads share the same Memory, Data, and Resources of the process, but each thread has its own Registers, Program Counter, and Stack. It improves system performance and responsiveness, especially in modern multi-core systems.
Advantages of Multithreading:
1. Improved Performance: Tasks run in parallel, increasing overall system speed.
2. Better Responsiveness: Applications remain responsive while performing background tasks.
3. Efficient Resource Sharing: Threads share memory and resources, reducing overhead.
4. Economical: Creating and managing threads is cheaper than processes.
Disadvantages of Multithreading:
1. Synchronization Problem: Requires proper synchronization to avoid data inconsistency.
2. Security Risk: Shared memory may cause security vulnerabilities.
3. Complex Debugging: Multithreaded programs are difficult to debug and maintain.
4. Deadlock Risk: Improper resource sharing may cause deadlocks.
In conclusion, Multithreading increases performance and responsiveness but requires careful synchronization and management.
Multithreading হলো এমন একটি পদ্ধতি যেখানে একটি Process-এর মধ্যে একাধিক Thread তৈরি করে একই সাথে (Concurrently) Execute করা হয়। এটি একটি Program-কে একই সময়ে একাধিক Task সম্পাদন করতে সহায়তা করে।
Multithreading-এ সকল Thread একই Memory, Data এবং Resource শেয়ার করে, তবে প্রতিটি Thread-এর নিজস্ব Registers, Program Counter এবং Stack থাকে। এটি বিশেষ করে Multi-core System-এ Performance ও Responsiveness বৃদ্ধি করে।
Multithreading-এর সুবিধাসমূহ:
১. Improved Performance: Parallelভাবে Task Execute করে System Speed বৃদ্ধি করে।
২. Better Responsiveness: Background Task চললেও Application Responsive থাকে।
৩. Efficient Resource Sharing: একই Memory ও Resource ব্যবহার করায় Overhead কম হয়।
৪. Economical: Process-এর তুলনায় Thread তৈরি ও পরিচালনা কম ব্যয়বহুল।
Multithreading-এর অসুবিধাসমূহ:
১. Synchronization Problem: সঠিক Synchronization না হলে Data Error হতে পারে।
২. Security Risk: Shared Memory কারণে Security ঝুঁকি থাকে।
৩. Complex Debugging: Multithread Program Debug করা কঠিন।
৪. Deadlock Risk: ভুল Resource Sharing-এর কারণে Deadlock হতে পারে।
সারসংক্ষেপে, Multithreading Performance ও Responsiveness বৃদ্ধি করে, তবে সঠিক Synchronization ও Management অত্যন্ত গুরুত্বপূর্ণ।
[/urcr_restrict]
Process Scheduling Algorithm
- 1What is Process Scheduling? Why it is important and What is Scheduler?
Process Scheduling is the process of selecting a process from the Ready Queue and allocating the CPU to it for execution. The Operating System uses a Scheduler to decide which process should run, when it should run, and how CPU resources should be allocated among competing processes.
The main purpose of Process Scheduling is to manage the CPU efficiently, keep the CPU busy as much as possible, provide fair access to processes, improve system performance, and reduce unnecessary waiting and response delays.
Scheduler: A Scheduler is an Operating System component that selects processes for execution according to a particular Scheduling Algorithm. It determines the order in which processes receive CPU time.
Why is Process Scheduling Important? In a multitasking Operating System, many processes may be ready to execute at the same time, but a single CPU core can execute only one process at a time. Therefore, the Operating System needs a proper mechanism to decide which process should receive the CPU. Process Scheduling provides this mechanism.
Types of CPU Scheduling:
1. Preemptive Scheduling
2. Non-Preemptive SchedulingProcess Scheduling হলো Ready Queue থেকে একটি Process নির্বাচন করে Execution-এর জন্য তাকে CPU প্রদান করার প্রক্রিয়া। Operating System একটি Scheduler ব্যবহার করে কোন Process চলবে, কখন চলবে এবং একাধিক Process-এর মধ্যে কীভাবে CPU Resource বণ্টন করা হবে তা নির্ধারণ করে।
Process Scheduling-এর প্রধান উদ্দেশ্য হলো CPU-কে কার্যকরভাবে পরিচালনা করা, যতটা সম্ভব CPU-কে ব্যস্ত রাখা, Process-গুলোর মধ্যে CPU ব্যবহারের ন্যায্য সুযোগ প্রদান করা, System Performance উন্নত করা এবং অপ্রয়োজনীয় Waiting Time ও Response Time কমানো।
Scheduler: Scheduler হলো Operating System-এর একটি গুরুত্বপূর্ণ Component, যা নির্দিষ্ট Scheduling Algorithm অনুসারে Execution-এর জন্য Process নির্বাচন করে। এটি কোন Process কোন ক্রমে CPU Time পাবে তা নির্ধারণ করে।
Why is Process Scheduling Important?
একটি Multitasking Operating System-এ একই সময়ে অনেক Process Execution-এর জন্য Ready থাকতে পারে। কিন্তু একটি Single CPU Core একই সময়ে শুধুমাত্র একটি Process Execute করতে পারে। তাই কোন Process-কে CPU দেওয়া হবে তা নির্ধারণ করার জন্য Operating System-এর একটি সঠিক পদ্ধতি প্রয়োজন। Process Scheduling এই ব্যবস্থা প্রদান করে এবং CPU-এর কার্যকর ও ন্যায্য ব্যবহার নিশ্চিত করতে সাহায্য করে।
Types of CPU Scheduling:
1. Preemptive Scheduling
2. Non-Preemptive Scheduling - 2Schedular in Operating System.
Schedulers are special System Software that manage Process Scheduling. Their main task is to select processes for execution and decide which Process will run on the CPU.
There are three types of Schedulers:
Long-Term Scheduler
Short-Term Scheduler
Medium-Term Scheduler1. Long-Term Scheduler (Job Scheduler):
It selects Processes from the Job Queue and loads them into Memory for execution. It controls the Degree of Multiprogramming and maintains a balanced mix of I/O-bound and CPU-bound Processes.
When a Process changes from New State to Ready State, the Long-Term Scheduler is involved. In many Time-Sharing Systems, the Long-Term Scheduler may be minimal or absent.
2. Short-Term Scheduler (CPU Scheduler):
It selects one Process from the Ready Queue and allocates the CPU to it. It changes the Process State from Ready to Running.
It works very fast and makes frequent scheduling decisions. The Short-Term Scheduler is also associated with the process of dispatching the selected Process to the CPU.
3. Medium-Term Scheduler:
It performs Swapping by removing Processes from Memory and placing them into Secondary Storage. This helps reduce the Degree of Multiprogramming and frees Memory space.
If a Process becomes Suspended, for example while waiting for I/O, it may be Swapped Out from Memory. Later, it can be Swapped In to Memory when it is ready to continue execution.
In conclusion, Schedulers help the Operating System manage CPU and Memory efficiently by selecting, controlling, and coordinating Process execution.
Schedulers হলো বিশেষ ধরনের System Software, যা Process Scheduling পরিচালনা করে। এদের প্রধান কাজ হলো কোন Process Execution-এর জন্য নির্বাচন করা হবে এবং কোন Process CPU-তে চলবে তা নির্ধারণ করা।
Scheduler প্রধানত তিন প্রকার:
Long-Term Scheduler
Short-Term Scheduler
Medium-Term Scheduler১. Long-Term Scheduler (Job Scheduler):
এটি Job Queue থেকে Process নির্বাচন করে Memory-তে লোড করে Execution-এর জন্য প্রস্তুত করে। এটি Degree of Multiprogramming নিয়ন্ত্রণ করে এবং I/O-bound ও CPU-bound Process-এর মধ্যে ভারসাম্য বজায় রাখে।
Process যখন New State থেকে Ready State-এ যায়, তখন Long-Term Scheduler-এর ভূমিকা থাকে। অনেক Time-Sharing System-এ Long-Term Scheduler খুব কম ব্যবহৃত হয় বা অনুপস্থিত থাকতে পারে।
২. Short-Term Scheduler (CPU Scheduler):
এটি Ready Queue থেকে একটি Process নির্বাচন করে তাকে CPU প্রদান করে। এর ফলে Process-এর State Ready থেকে Running-এ পরিবর্তিত হয়।
এটি খুব দ্রুত কাজ করে এবং ঘন ঘন Scheduling Decision গ্রহণ করে। নির্বাচিত Process-কে CPU-তে পাঠানোর ক্ষেত্রে এটি Dispatching-এর সঙ্গে সম্পর্কিত।
৩. Medium-Term Scheduler:
এটি Swapping পরিচালনা করে। অর্থাৎ Memory থেকে কিছু Process সরিয়ে Secondary Storage-এ পাঠায়। এর ফলে Degree of Multiprogramming কমানো যায় এবং Memory-এর স্থান খালি করা যায়।
কোনো Process Suspended হলে, যেমন I/O-এর জন্য অপেক্ষা করার সময়, সেটিকে Memory থেকে Swap Out করা হতে পারে। পরবর্তীতে Process পুনরায় Execution চালিয়ে যাওয়ার উপযোগী হলে সেটিকে Swap In করে Memory-তে আনা যায়।
সারসংক্ষেপে, Schedulers Process নির্বাচন, নিয়ন্ত্রণ এবং Execution পরিচালনার মাধ্যমে Operating System-এর CPU ও Memory কার্যকরভাবে ব্যবস্থাপনা করতে সাহায্য করে।
- 3Preemptive Scheduling and its Pros & Cons
Preemptive Scheduling: In Preemptive Scheduling, the Operating System can interrupt a currently running process and allocate the CPU to another process. This can happen when a higher-priority process arrives or when a Scheduling Algorithm decides that another process should receive the CPU.
Preemptive Scheduling is commonly used in modern multitasking Operating Systems because it allows the system to switch between processes and provide better responsiveness. It generally provides better Response Time and can improve CPU Utilization when properly implemented.
Advantages of Preemptive Scheduling:
It provides better responsiveness in interactive systems.
It allows the Operating System to interrupt a running process when necessary.
It supports effective multitasking.
It can provide better CPU sharing among multiple processes.Disadvantages of Preemptive Scheduling:
Frequent Context Switching can introduce overhead.
The implementation is more complex than Non-Preemptive Scheduling.
Shared data may require careful synchronization because processes can be interrupted during execution.Examples of Preemptive Scheduling Algorithms: Round Robin, Shortest Remaining Time First (SRTF), and Preemptive Priority Scheduling are examples of Preemptive Scheduling techniques.
Preemptive Scheduling-এ Operating System বর্তমানে চলমান একটি Process-কে interrupt করে অন্য একটি Process-কে CPU দিতে পারে। কোনো Higher-Priority Process আসলে অথবা Scheduling Algorithm অনুযায়ী অন্য কোনো Process-কে CPU দেওয়ার প্রয়োজন হলে এটি ঘটতে পারে।
আধুনিক Multitasking Operating Systems-এ Preemptive Scheduling ব্যাপকভাবে ব্যবহৃত হয়, কারণ এটি বিভিন্ন Process-এর মধ্যে CPU দ্রুত পরিবর্তন করার সুযোগ দেয় এবং System-এর responsiveness বৃদ্ধি করে। এটি সাধারণত ভালো Response Time প্রদান করে এবং সঠিকভাবে বাস্তবায়ন করা হলে CPU Utilization উন্নত করতে পারে।
Advantages of Preemptive Scheduling:
Interactive System-এ ভালো responsiveness প্রদান করে।
প্রয়োজন অনুযায়ী Operating System চলমান Process-কে interrupt করতে পারে।
কার্যকর Multitasking সমর্থন করে।
একাধিক Process-এর মধ্যে CPU আরও কার্যকরভাবে ভাগ করে দিতে পারে।Disadvantages of Preemptive Scheduling:
বারবার Context Switching হলে অতিরিক্ত overhead তৈরি হতে পারে।
Non-Preemptive Scheduling-এর তুলনায় এর implementation বেশি complex।
Execution-এর সময় Process interrupt হতে পারে বলে Shared Data-এর ক্ষেত্রে সতর্কতার সঙ্গে synchronization প্রয়োজন হতে পারে।Examples of Preemptive Scheduling Algorithms:
Round Robin (RR)
Shortest Remaining Time First (SRTF)
Preemptive Priority Scheduling - 4Non- Preemptive Scheduling and its Pros & Cons
Non-Preemptive Scheduling: In Non-Preemptive Scheduling, once a process is allocated the CPU, it normally continues execution until it terminates or voluntarily enters a waiting state, such as waiting for an Input/Output operation. The Operating System does not forcibly remove the CPU from the running process simply to give it to another process.
Non-Preemptive Scheduling is simpler to implement because the running process is not normally interrupted by the Scheduler. However, a long-running process can make other processes wait for a significant amount of time.
Advantages of Non-Preemptive Scheduling:
It is simple and easier to implement.
It generally requires fewer Context Switches.
Scheduling overhead is relatively low.
It is suitable for systems where process execution should not be forcibly interrupted.Disadvantages of Non-Preemptive Scheduling:
A long-running process can make other processes wait for a long time.
Response Time can be poor for interactive workloads.
It provides less flexibility for the Operating System to immediately change CPU allocation.Examples of Non-Preemptive Scheduling Algorithms: First Come First Serve (FCFS) and the basic version of Shortest Job First (SJF) are examples of Non-Preemptive Scheduling Algorithms.
Non-Preemptive Scheduling-এ কোনো Process-কে একবার CPU দেওয়া হলে সেটি সাধারণত Terminate না হওয়া পর্যন্ত অথবা স্বেচ্ছায় কোনো Waiting State-এ না যাওয়া পর্যন্ত Execution চালিয়ে যায়। যেমন, কোনো Process Input/Output operation-এর জন্য অপেক্ষা করতে পারে। অন্য Process-কে CPU দেওয়ার জন্য Operating System জোরপূর্বক Running Process-এর কাছ থেকে CPU নিয়ে নেয় না।
Non-Preemptive Scheduling বাস্তবায়ন করা তুলনামূলকভাবে সহজ, কারণ Running Process-কে সাধারণত Scheduler দ্বারা মাঝপথে Interrupt করা হয় না। তবে কোনো Process দীর্ঘ সময় ধরে CPU ব্যবহার করলে অন্যান্য Process-কে দীর্ঘ সময় অপেক্ষা করতে হতে পারে।
Advantages of Non-Preemptive Scheduling:
এটি সহজ এবং সহজে Implement করা যায়।
সাধারণত কম Context Switching প্রয়োজন হয়।
Scheduling overhead তুলনামূলকভাবে কম।
যেসব System-এ Process Execution-কে জোরপূর্বক Interrupt না করাই উপযুক্ত, সেসব System-এর জন্য এটি কার্যকর।Disadvantages of Non-Preemptive Scheduling:
দীর্ঘ সময় ধরে চলা কোনো Process-এর কারণে অন্যান্য Process-কে দীর্ঘ সময় অপেক্ষা করতে হতে পারে।
Interactive Workload-এর ক্ষেত্রে Response Time খারাপ হতে পারে।
Operating System-এর জন্য CPU Allocation তাৎক্ষণিকভাবে পরিবর্তন করার flexibility কম থাকে।Examples of Non-Preemptive Scheduling Algorithms:
First Come First Serve (FCFS)
Shortest Job First (SJF)
- 5Preemptive Scheduling vs Non Preemptive
- 6Important Terminologies in Process Scheduling
CPU Utilization: CPU Utilization indicates how much of the CPU is being used. The main goal is to keep the CPU as busy as possible and minimize CPU idle time. Conceptually, CPU Utilization can range from 0% to 100%. In a real system, it may range from about 40% for a lightly loaded system to about 90% for a heavily used system.
Throughput: Throughput measures the amount of work completed by the CPU per unit of time. It is defined as the number of processes completed per unit of time. A higher Throughput generally means that more processes are being completed in a given period.
Arrival Time (AT): Arrival Time is the time at which a process enters the Ready Queue and becomes available for CPU execution.
Burst Time (BT): Burst Time is the amount of CPU time required by a process for its execution during a CPU burst.
Completion Time (CT): Completion Time is the time at which a process finishes its execution.
Turnaround Time (TAT): Turnaround Time is the total time taken by a process from its Arrival Time until its Completion Time. The formula is: Turnaround Time = Completion Time − Arrival Time.
Waiting Time (WT): Waiting Time is the total amount of time a process spends waiting in the Ready Queue for CPU allocation. For the standard scheduling calculations, the formula is: Waiting Time = Turnaround Time − Burst Time.
Response Time (RT): Response Time is the time from the arrival or submission of a process until the process receives CPU service for the first time. It is especially important in interactive systems.
Gantt Chart: A Gantt Chart is a graphical representation of CPU Scheduling. It shows the order in which processes are executed and the time intervals during which each process occupies the CPU. It is very useful for calculating Completion Time, Turnaround Time, Waiting Time, and Response Time.
CPU Scheduling Criteria: Different Scheduling Algorithms can be compared using several important criteria. CPU Utilization measures how effectively the CPU is kept busy. Throughput measures the number of processes completed per unit of time. Turnaround Time measures the total time from process submission to completion. Waiting Time measures the time spent waiting in the Ready Queue. Response Time measures how quickly the system provides the first response.
- Key Points to Remember:
- CPU Utilization → Keep the CPU as busy as possible.
- Throughput → Number of processes completed per unit time.
- Turnaround Time → Total time from process submission to completion.
- Waiting Time → Total time spent waiting in the Ready Queue.
- Response Time → Time from request submission to the first response.
CPU Utilization: CPU Utilization দ্বারা বোঝায় CPU-এর কতটুকু সময় ব্যবহার হচ্ছে। এর প্রধান উদ্দেশ্য হলো CPU-কে যতটা সম্ভব ব্যস্ত রাখা এবং CPU-এর Idle Time কমানো। ধারণাগতভাবে CPU Utilization 0% থেকে 100% পর্যন্ত হতে পারে। বাস্তব System-এ Lightly Loaded System-এ এটি প্রায় 40% এবং Heavily Used System-এ প্রায় 90% হতে পারে।
Throughput: Throughput দ্বারা প্রতি একক সময়ে CPU কতটুকু কাজ সম্পন্ন করছে তা বোঝায়। এটি প্রতি একক সময়ে সম্পন্ন হওয়া Process-এর সংখ্যা দ্বারা প্রকাশ করা হয়। Throughput বেশি হলে সাধারণত নির্দিষ্ট সময়ের মধ্যে বেশি Process সম্পন্ন হয়।
Arrival Time (AT): Arrival Time হলো সেই সময়, যখন কোনো Process Ready Queue-তে প্রবেশ করে এবং CPU Execution-এর জন্য Available হয়।
Burst Time (BT): Burst Time হলো একটি Process-এর CPU Burst-এর সময় Execution সম্পন্ন করার জন্য প্রয়োজনীয় CPU Time।
Completion Time (CT): Completion Time হলো সেই সময়, যখন কোনো Process তার Execution সম্পন্ন করে।
Turnaround Time (TAT): Turnaround Time হলো কোনো Process-এর Arrival Time থেকে Completion Time পর্যন্ত মোট সময়।
Turnaround Time = Completion Time − Arrival TimeWaiting Time (WT): Waiting Time হলো কোনো Process-এর CPU পাওয়ার জন্য Ready Queue-তে অপেক্ষা করার মোট সময়।
Waiting Time = Turnaround Time − Burst TimeResponse Time (RT): Response Time হলো কোনো Process-এর Arrival বা Submission থেকে প্রথমবার CPU Service পাওয়া পর্যন্ত সময়। এটি বিশেষভাবে Interactive Systems-এর জন্য গুরুত্বপূর্ণ।
Gantt Chart: Gantt Chart হলো CPU Scheduling-এর একটি Graphical Representation। এটি কোন Process কোন ক্রমে Execute হয়েছে এবং কোন সময়সীমায় প্রতিটি Process CPU ব্যবহার করেছে তা দেখায়। এটি Completion Time, Turnaround Time, Waiting Time এবং Response Time নির্ণয়ের জন্য খুবই গুরুত্বপূর্ণ।
CPU Scheduling Criteria: বিভিন্ন Scheduling Algorithm-এর Performance তুলনা করার জন্য কয়েকটি গুরুত্বপূর্ণ Criteria ব্যবহার করা হয়। CPU Utilization CPU কতটা কার্যকরভাবে ব্যস্ত রাখা হচ্ছে তা নির্দেশ করে। Throughput প্রতি একক সময়ে কতটি Process সম্পন্ন হচ্ছে তা নির্দেশ করে। Turnaround Time Process Submission থেকে Completion পর্যন্ত মোট সময় নির্দেশ করে। Waiting Time Ready Queue-তে অপেক্ষা করার সময় নির্দেশ করে। Response Time System কত দ্রুত প্রথম Response প্রদান করে তা নির্দেশ করে।
Key Points to Remember:
CPU Utilization → CPU-কে যতটা সম্ভব ব্যস্ত রাখা।
Throughput → প্রতি একক সময়ে সম্পন্ন হওয়া Process-এর সংখ্যা।
Arrival Time → Process Ready Queue-তে প্রবেশ করার সময়।
Burst Time → Process-এর Execution-এর জন্য প্রয়োজনীয় CPU Time।
Completion Time → Process-এর Execution শেষ হওয়ার সময়।
Turnaround Time → Process Submission থেকে Completion পর্যন্ত মোট সময়।
Waiting Time → Ready Queue-তে অপেক্ষা করার মোট সময়।
Response Time → Process Arrival বা Submission থেকে প্রথম CPU Service পাওয়া পর্যন্ত সময়।
Gantt Chart → Process Execution এবং CPU Scheduling-এর Graphical Representation।
- 7First Come First Serve (FCFS), Convoy Effect
FCFS is one of the simplest CPU Scheduling Algorithms. In FCFS, the process that arrives first is normally served first. The processes are handled according to their Arrival Time, following a first-come, first-served order.
FCFS is a Non-Preemptive Scheduling Algorithm. Once a process gets the CPU, it normally continues execution until its CPU burst is completed or it enters a waiting state. The CPU then selects the next eligible process according to the FCFS order.
Characteristics of FCFS:
FCFS follows the first-come, first-served principle.
FCFS is a Non-Preemptive Scheduling Algorithm.
Processes are generally executed according to their Arrival Time.
It is simple and easy to implement.
It requires relatively simple scheduling logic.
It may cause long Waiting Time for processes that arrive behind a long CPU-bound process.
FCFS can suffer from the Convoy Effect, where short processes are forced to wait behind a long process.Convoy Effect: The Convoy Effect occurs when several short processes have to wait for a long CPU-bound process because of the FCFS execution order. As a result, the average Waiting Time and Response Time can increase.
FCFS and Preemption: FCFS is classified as a Non-Preemptive Scheduling Algorithm. When a process starts running under FCFS, another newly arrived process does not normally interrupt it. The new process waits until the currently running process finishes its CPU burst or enters a waiting state.
First Come First Serve (FCFS): FCFS হলো সবচেয়ে সহজ CPU Scheduling Algorithm-গুলোর একটি। FCFS-এ যে Process আগে আসে, সাধারণত সেই Process-ই আগে CPU Service পায়। অর্থাৎ Process-এর Arrival Time অনুসারে First-Come, First-Served Order অনুসরণ করা হয়।
FCFS একটি Non-Preemptive Scheduling Algorithm। কোনো Process CPU পাওয়ার পর সাধারণত তার CPU Burst শেষ না হওয়া পর্যন্ত অথবা কোনো Waiting State-এ যাওয়া পর্যন্ত Execution চালিয়ে যায়। এরপর FCFS Order অনুসারে পরবর্তী উপযুক্ত Process CPU পায়।
FCFS-এর বৈশিষ্ট্য:
FCFS First-Come, First-Served Principle অনুসরণ করে।
FCFS একটি Non-Preemptive Scheduling Algorithm।
Process সাধারণত Arrival Time অনুসারে Execute হয়।
এটি সহজ এবং Implement করা সহজ।
এর Scheduling Logic তুলনামূলকভাবে সহজ।
কোনো দীর্ঘ CPU-Bound Process আগে এলে তার পিছনে থাকা Short Process-গুলোর Waiting Time অনেক বেড়ে যেতে পারে।
FCFS-এ Convoy Effect দেখা দিতে পারে, যেখানে একটি দীর্ঘ Process-এর কারণে অনেক Short Process অপেক্ষা করতে বাধ্য হয়।Convoy Effect: Convoy Effect হলো এমন একটি পরিস্থিতি যেখানে FCFS Execution Order-এর কারণে অনেক Short Process-কে একটি দীর্ঘ CPU-Bound Process-এর পিছনে অপেক্ষা করতে হয়। এর ফলে Average Waiting Time এবং Response Time বৃদ্ধি পেতে পারে।
FCFS এবং Preemption: FCFS একটি Non-Preemptive Scheduling Algorithm। FCFS-এর অধীনে কোনো Process Running শুরু করলে নতুন কোনো Process Arrival করলেও সাধারণত সেটি Running Process-কে Interrupt করতে পারে না। নতুন Process-কে অপেক্ষা করতে হয় যতক্ষণ না বর্তমান Process তার CPU Burst শেষ করে অথবা Waiting State-এ যায়।
- 8Find Gant Chart, Average Waiting time and Burst Time by FCFS Scheduling Algorithm

- 9FCFS CPU Scheduling (Processes with Same Arrival Time):
Consider the following table of arrival time and burst time for three processes P1, P2 and P3
Find avg Turnaround & Waiting TimeProcess Arrival Time Burst Time p1 0 5 p2 0 3 p3 0 8 
- Turnaround Time (TAT) = CT - AT
- Waiting Time (WT) = TAT - BT
- Start Time (ST) = max(AT, Previous CT)
- Finish Time (FT) / Completion Time (CT) = ST + BT
- Waiting Time (WT) = ST - AT
- Turnaround Time (TAT) = FT - AT
- 10

- 11Shortest Job First (SJF) Scheduling Algorithm
Shortest Job First (SJF) is a CPU Non-Preemptive Scheduling Algorithm used in Operating Systems. In this algorithm, the CPU is allocated to the process that has the shortest Burst Time, meaning the process that requires the least amount of CPU execution time is selected first.
Since SJF is a Non-Preemptive Scheduling Algorithm, once a process gets the CPU, it continues its execution until its CPU Burst is completed. The CPU is then assigned to the next eligible process with the shortest Burst Time.
Basic Working Principle:
The Scheduler checks the available processes in the Ready Queue.
The process having the shortest Burst Time is selected for execution.
The selected process continues until its execution is completed.
After completion, the Scheduler selects the next process with the shortest Burst Time among the available processes.Important Point: If two or more processes have the same Burst Time, they are scheduled according to FCFS (First Come First Serve). Therefore, when Burst Times are equal, the process that arrived earlier is selected first.
Main Characteristics of SJF:
SJF is a Non-Preemptive CPU Scheduling Algorithm.
It selects the process with the shortest Burst Time first.
Burst Time means the amount of CPU time required by a process for execution.
If two or more processes have equal Burst Time, FCFS is used to decide their order.
SJF provides the minimum average waiting time among the standard non-preemptive scheduling algorithms, when the required Burst Times are known.Advantage of SJF: The major advantage of SJF is that it can minimize the average waiting time. Short processes are completed earlier, so processes generally spend less time waiting in the Ready Queue compared with many other scheduling approaches.
Limitation of SJF: The Scheduler needs to know or estimate the Burst Time of processes before making the scheduling decision. In a real system, accurately knowing the future CPU Burst Time may not always be possible. Also, a long process may have to wait for a long time if many shorter processes continue to arrive.
Applications of SJF:
SJF can be useful in Batch Processing Operating Systems, where jobs can be scheduled according to their expected execution time.
It can also be applied in some Embedded Systems where predictable workloads are available.
SJF may also be considered for Compiler Job Scheduling or similar environments where the execution time of jobs can be estimated.Key Formula for SJF Problems:
Turnaround Time = Completion Time − Arrival Time
Waiting Time = Turnaround Time − Burst TimeExam Important Points:
SJF stands for Shortest Job First.
SJF selects the process with the shortest Burst Time.
Standard SJF is a Non-Preemptive scheduling algorithm.
For equal Burst Times, FCFS is used.
SJF provides the minimum average waiting time when Burst Times are known and under the usual scheduling assumptions.
The preemptive counterpart of SJF is commonly called SRTF (Shortest Remaining Time First).
Shortest Job First (SJF) হলো Operating System-এর একটি CPU Non-Preemptive Scheduling Algorithm। এই Algorithm-এ যে Process-এর Burst Time সবচেয়ে কম, অর্থাৎ যে Process-এর CPU Execution-এর জন্য সবচেয়ে কম সময় প্রয়োজন, সেই Process-কে প্রথমে CPU দেওয়া হয়।
SJF একটি Non-Preemptive Scheduling Algorithm হওয়ায় কোনো Process একবার CPU পেলে তার CPU Burst সম্পূর্ণ না হওয়া পর্যন্ত সেটি CPU ব্যবহার করতে থাকে। Process-এর Execution শেষ হলে Scheduler পরবর্তী Available Process-গুলোর মধ্যে সবচেয়ে কম Burst Time-যুক্ত Process নির্বাচন করে।
SJF-এর কাজের মূলনীতি:
Scheduler প্রথমে Ready Queue-তে থাকা Available Process-গুলো পরীক্ষা করে।
যে Process-এর Burst Time সবচেয়ে কম, সেটিকে Execution-এর জন্য নির্বাচন করা হয়।
নির্বাচিত Process-এর Execution সম্পূর্ণ না হওয়া পর্যন্ত এটি CPU ব্যবহার করে।
Process-এর Execution শেষ হলে Available Process-গুলোর মধ্যে আবার সবচেয়ে কম Burst Time-যুক্ত Process নির্বাচন করা হয়।গুরুত্বপূর্ণ বিষয়: যদি দুই বা ততোধিক Process-এর Burst Time একই হয়, তাহলে তাদের Scheduling Order নির্ধারণের জন্য FCFS (First Come First Serve) ব্যবহার করা হয়। অর্থাৎ, একই Burst Time হলে যে Process আগে Arrive করেছে সেটি আগে CPU পাবে।
SJF-এর প্রধান বৈশিষ্ট্য:
SJF একটি Non-Preemptive CPU Scheduling Algorithm।
এটি প্রথমে সবচেয়ে কম Burst Time-যুক্ত Process নির্বাচন করে।
Burst Time হলো কোনো Process-এর Execution-এর জন্য প্রয়োজনীয় CPU Time।
দুই বা ততোধিক Process-এর Burst Time সমান হলে FCFS ব্যবহার করে তাদের Order নির্ধারণ করা হয়।
Standard Non-Preemptive Scheduling Algorithm-এর মধ্যে SJF সাধারণত Minimum Average Waiting Time প্রদান করে, যখন Process-এর Burst Time জানা থাকে।SJF-এর সুবিধা: SJF-এর প্রধান সুবিধা হলো এটি Average Waiting Time কমাতে পারে। ছোট Process-গুলো আগে সম্পন্ন হওয়ার কারণে অনেক ক্ষেত্রে Process-গুলোকে Ready Queue-তে অপেক্ষা করতে কম সময় লাগে।
SJF-এর সীমাবদ্ধতা: Scheduling Decision নেওয়ার জন্য Scheduler-এর Process-এর Burst Time জানা অথবা Estimate করা প্রয়োজন। বাস্তব System-এ কোনো Process ভবিষ্যতে ঠিক কত সময় CPU ব্যবহার করবে তা সবসময় নির্ভুলভাবে জানা সম্ভব নয়। এছাড়া অনেক Short Process ধারাবাহিকভাবে আসতে থাকলে কোনো Long Process দীর্ঘ সময় অপেক্ষা করতে পারে।
SJF-এর ব্যবহার:
Batch Processing Operating System-এ SJF ব্যবহার করা যেতে পারে, যেখানে Job-এর সম্ভাব্য Execution Time অনুযায়ী Scheduling করা সম্ভব।
কিছু Embedded System-এও এটি ব্যবহার করা যেতে পারে, বিশেষ করে যেখানে Workload তুলনামূলকভাবে Predictable।
এছাড়া Compiler Job Scheduling বা অনুরূপ কিছু Environment-এ, যেখানে Job-এর Execution Time Estimate করা যায়, সেখানে SJF বিবেচনা করা যেতে পারে।SJF Problem-এর গুরুত্বপূর্ণ Formula:
Turnaround Time = Completion Time − Arrival Time
Waiting Time = Turnaround Time − Burst Timeপরীক্ষার জন্য গুরুত্বপূর্ণ বিষয়:
SJF-এর পূর্ণরূপ হলো Shortest Job First।
SJF সবচেয়ে কম Burst Time-যুক্ত Process নির্বাচন করে।
Standard SJF একটি Non-Preemptive Scheduling Algorithm।
সমান Burst Time হলে FCFS ব্যবহার করা হয়।
Burst Time জানা থাকলে এবং সাধারণ Scheduling Assumption অনুযায়ী SJF Minimum Average Waiting Time প্রদান করে।
SJF-এর Preemptive counterpart-কে সাধারণত SRTF (Shortest Remaining Time First) বলা হয়।
- 12
Process No. Arrival Time Burst Time A 1 3 B 2 4 C 1 2 B 4 4
Using the above table, solve the following question using the Shortest Job First (SJF) non-preemptive scheduling algorithm:
Calculate the Gantt chart, Completion Time (CT), Turnaround Time (TAT), Waiting Time (WT), and average waiting time for all processes.
- 13
Process No. Arrival Time Burst Time P1 0 6 P2 4 10 P3 4 4 P4 8 3
Using the above table, solve the following question using the Shortest Job First (SJF) non-preemptive scheduling algorithm.
Calculate the Gantt Chart, Completion Time (CT), Turnaround Time (TAT), Waiting Time (WT), and Average Waiting Time for all processes.
- 14Shortest Remaining Time First (SRTF) Scheduling Algorithm
Shortest Remaining Time First (SRTF) is a CPU Preemptive Scheduling Algorithm. It is also known as the Preemptive version of Shortest Job First (SJF).
In SRTF, the process with the smallest remaining Burst Time is selected to execute next. If a new process arrives with a smaller remaining Burst Time than the currently running process, the current process is preempted and the newly arrived process gets the CPU.
SRTF can provide a minimum average Waiting Time under the standard scheduling assumptions. However, processes with longer Burst Times may experience prolonged waiting if shorter processes continue to arrive.
Applications:
Batch Processing OS
Embedded Systems
Real-Time SystemsShortest Remaining Time First (SRTF) হলো একটি CPU Preemptive Scheduling Algorithm। এটিকে Shortest Job First (SJF)-এর Preemptive version হিসেবেও বলা হয়।
SRTF-এ যে Process-এর Remaining Burst Time সবচেয়ে কম, সেটিকে পরবর্তী সময়ে CPU execution-এর জন্য নির্বাচন করা হয়। বর্তমানে একটি Process CPU-তে চলার সময় যদি নতুন কোনো Process আসে এবং তার Remaining Burst Time বর্তমান Process-এর চেয়ে কম হয়, তাহলে বর্তমান Process-কে Preempt করে নতুন Process-কে CPU দেওয়া হয়।
SRTF সাধারণ Scheduling assumptions-এর অধীনে minimum average Waiting Time প্রদান করতে পারে। তবে দীর্ঘ Burst Time-এর Process-এর ক্ষেত্রে বারবার ছোট Process আসতে থাকলে Waiting Time অনেক বেড়ে যেতে পারে।
Applications:
Batch Processing OS
Embedded Systems
Real-Time Systems - 15
Process No. Arrival Time Burst Time P1 1 1 P2 3 2 P3 2 1 P4 0 4
Using the above table, solve the scheduling problem using the Shortest Remaining Time First (SRTF), also known as SJF Preemptive, scheduling algorithm.
Calculate the Gantt Chart, Completion Time (CT), Turnaround Time (TAT), Waiting Time (WT), and Average Waiting Time for all processes.
- 16Using preemptive SJF (SRTN) scheduling on the following processes, draw GANTT chart and find the average turnaround time and average waiting time.
Process Arrival Time CPU Burst Time P1 0 8 P2 4 10 P3 4 3 P4 10 4 
- Turnaround Time (TAT) = FinishT - ArrivalT
- Waiting Time (WT) = TAT - BT
- Start Time (ST) = max(AT, Previous CT)
- Finish Time (FT) / Completion Time (CT) = ST + BT
- Waiting Time (WT) = ST - AT
- Turnaround Time (TAT) = FT - AT
- 17Round Robin (RR) Scheduling Algorithm
Round Robin (RR) is a Preemptive CPU Scheduling Algorithm in which each Process is assigned a fixed time slice called a Time Quantum. Each Process gets an equal opportunity to use the CPU in a circular order.
When a Process gets CPU access, it executes for the given Time Quantum. If the Process is not completed within that time, it is Preempted and moved to the end of the Ready Queue. Then, the next Process in the queue gets the CPU.
Processes are generally added to the Ready Queue according to the First Come First Serve (FCFS) rule. Since a running Process can be interrupted when its Time Quantum expires, Round Robin is a Preemptive Scheduling Algorithm.
Features of Round Robin Scheduling:
All Processes get an equal opportunity to execute.
It is a fair Scheduling Strategy.
It is a Preemptive Scheduling Method.
Processes execute in a turn-wise or circular manner.
It generally prevents indefinite starvation of Processes.
Its performance depends heavily on the selected Time Quantum.
It is simple and widely used in Time-Sharing Systems.Applications:
Operating Systems
Networking
Multitasking Systems
Embedded Systems
Cloud Computing
Round Robin (RR) হলো একটি Preemptive CPU Scheduling Algorithm, যেখানে প্রতিটি Process-এর জন্য একটি নির্দিষ্ট time slice নির্ধারণ করা হয়, যাকে Time Quantum বলা হয়। প্রতিটি Process একটি circular order-এ CPU ব্যবহারের সমান সুযোগ পায়।
কোনো Process CPU পাওয়ার পর নির্ধারিত Time Quantum পর্যন্ত execute করে। এই সময়ের মধ্যে Process সম্পূর্ণ না হলে সেটিকে Preempt করে Ready Queue-এর শেষে পাঠানো হয়। এরপর Queue-এর পরবর্তী Process-কে CPU দেওয়া হয়।
Processes সাধারণত First Come First Serve (FCFS) নিয়ম অনুসারে Ready Queue-তে প্রবেশ করে। Running Process-এর Time Quantum শেষ হলে সেটিকে interrupt করা যায় বলে Round Robin একটি Preemptive Scheduling Algorithm।
Features of Round Robin Scheduling:
সব Process সমানভাবে Execution-এর সুযোগ পায়।
এটি একটি Fair Scheduling Strategy।
এটি একটি Preemptive Scheduling Method।
Processes turn-wise বা circular manner-এ execute করে।
সাধারণভাবে কোনো Process দীর্ঘ সময় ধরে অনির্দিষ্টভাবে অপেক্ষা করে থাকে না।
এর Performance নির্বাচিত Time Quantum-এর উপর অনেক বেশি নির্ভর করে।
এটি সহজ এবং Time-Sharing Systems-এ ব্যাপকভাবে ব্যবহৃত হয়।Applications:
Operating Systems
Networking
Multitasking Systems
Embedded Systems
Cloud Computing - 18
Process No. Arrival Time Burst Time P1 0 5 P2 1 4 P3 2 2 P4 4 1
Time Quantum = 2
Using Round Robin CPU scheduling, draw the Gantt chart and calculate the Completion Time (CT), Turnaround Time (TAT), Waiting Time (WT), and Response Time (RT) for each process.
Also calculate the Average Turnaround Time, Average Waiting Time, and Average Response Time.
- 19Consider the following set of processes whose arrival times, burst times are give in the following table −
Time Quantum=4 . Draw the GANTT chart and find the average turnaround time and average waiting time.Process Arrival Time Burst Time P1 2 8 P2 0 7 P3 1 9 
- Turnaround Time (TAT) = FinishT - ArrivalT
- Waiting Time (WT) = TAT - BT
- Start Time (ST) = max(AT, Previous CT)
- Finish Time (FT) / Completion Time (CT) = ST + BT
- Waiting Time (WT) = ST - AT
- Turnaround Time (TAT) = FT - AT
- 20Priority Scheduling Algorithm
Priority Scheduling is a CPU Scheduling Algorithm in which each Process is assigned a Priority Value. The CPU is allocated to the Process with the Highest Priority. In many systems, a lower numerical value represents a higher priority.
If two or more Processes have the same Priority, another Scheduling Method such as FCFS (First Come First Serve) can be used to decide which Process will execute first.
Non-Preemptive Priority Scheduling
In Non-Preemptive Priority Scheduling, once a Process gets the CPU, it continues execution until completion. The Scheduler selects the highest-priority Process from the Ready Queue. The Scheduler makes a new decision when a Process completes or when a new Process arrives while the Ready Queue was previously empty.
Preemptive Priority Scheduling
In Preemptive Priority Scheduling, if a new Process arrives with a higher priority than the currently running Process, the running Process is Preempted and the newly arrived higher-priority Process gets the CPU immediately.
The Scheduler makes a decision when a new Process arrives or when an existing Process completes. Preemptive Priority Scheduling provides faster response to high-priority Processes, which makes it useful in systems where some Processes require more urgent execution.
Applications:
Real-Time Systems
Interactive Systems
Multimedia Applications
Medical and Emergency SystemsPriority Scheduling হলো একটি CPU Scheduling Algorithm, যেখানে প্রতিটি Process-এর জন্য একটি Priority Value নির্ধারণ করা হয়। যে Process-এর Priority সবচেয়ে বেশি, CPU তাকে Execution-এর জন্য প্রদান করা হয়। অনেক System-এ কম Numerical Value-কে বেশি Priority হিসেবে বিবেচনা করা হয়।
দুই বা ততোধিক Process-এর Priority একই হলে কোন Process আগে Execute করবে তা নির্ধারণের জন্য FCFS (First Come First Serve)-এর মতো অন্য কোনো Scheduling Method ব্যবহার করা যেতে পারে।
Non-Preemptive Priority Scheduling
Non-Preemptive Priority Scheduling-এ কোনো Process একবার CPU পেলে সেটি Completion পর্যন্ত Execution চালিয়ে যায়। Scheduler Ready Queue থেকে সর্বোচ্চ Priority-এর Process নির্বাচন করে। কোনো Process Complete হলে অথবা Ready Queue আগে Empty থাকা অবস্থায় নতুন Process আসলে Scheduler নতুন সিদ্ধান্ত গ্রহণ করে।
Preemptive Priority Scheduling
Preemptive Priority Scheduling-এ বর্তমানে একটি Process CPU-তে চলার সময় যদি তার চেয়ে বেশি Priority-এর কোনো নতুন Process আসে, তাহলে Running Process-কে Preempt করা হয় এবং নতুন আসা Higher-Priority Process-কে সঙ্গে সঙ্গে CPU দেওয়া হয়।
নতুন Process আসলে অথবা কোনো Existing Process Complete হলে Scheduler নতুন সিদ্ধান্ত গ্রহণ করে। Preemptive Priority Scheduling High-Priority Process-কে দ্রুত CPU পাওয়ার সুযোগ দেয়, তাই যেখানে কিছু Process-এর Execution বেশি জরুরি, সেখানে এটি কার্যকর।
Applications:
Real-Time Systems
Interactive Systems
Multimedia Applications
Medical and Emergency Systems - 21Suppose that we have a set of four processes that have arrived at the same time in the order P1, P2, P3 and P4. The burst time in milliseconds and their priorities of the processes is given by the following table −
Considering that a lower priority value means higher priority, perform non-preemptive priority scheduling on it. Draw the GANTT chart and find the average turnaround time and average waiting time.Process Arrival Time CPU Burst Time Priority P1 0 6 2 P2 4 10 1 P3 4 4 2 P4 8 3 1 
- Turnaround Time (TAT) = FinishT - ArrivalT
- Waiting Time (WT) = TAT - BT
- Start Time (ST) = max(AT, Previous CT)
- Finish Time (FT) / Completion Time (CT) = ST + BT
- Waiting Time (WT) = ST - AT
- Turnaround Time (TAT) = FT - AT
- 22Consider the following set of processes whose arrival times, burst times and priorities are give in the following table −
Considering that a lower priority value means higher priority, perform preemptive priority scheduling on it. Draw the GANTT chart and find the average turnaround time and average waiting time.Process Arrival Time CPU Burst Time Priority P1 0 8 3 P2 4 10 2 P3 4 3 3 P4 10 4 1 
- Turnaround Time (TAT) = FinishT - ArrivalT
- Waiting Time (WT) = TAT - BT
- Start Time (ST) = max(AT, Previous CT)
- Finish Time (FT) / Completion Time (CT) = ST + BT
- Waiting Time (WT) = ST - AT
- Turnaround Time (TAT) = FT - AT
Deadlock
Memory Management
Page Replacement Technique
Paging in Operating System
Paging is a memory management technique where physical memory (RAM) is divided into fixed-size blocks called Frames and logical memory is divided into equal-sized blocks called Pages.
When a process executes, its pages are loaded into available frames in RAM. Paging helps efficient memory utilization and supports virtual memory.
Page Table
A Page Table is a data structure maintained by the operating system that stores the mapping between logical addresses (pages) and physical addresses (frames).
The operating system uses the page table to determine where a page is located in physical memory.
Page Fault
A Page Fault occurs when a process tries to access a page that is not currently available in physical memory (RAM).
In this situation:
- The operating system checks the page table.
- The required page is loaded from the hard disk into RAM.
- The page table is updated.
- Then the CPU continues execution.
Operating System-এ Paging
Paging হলো একটি memory management technique যেখানে physical memory (RAM)-কে fixed-size block-এ ভাগ করা হয়, যেগুলোকে Frames বলা হয় এবং logical memory-কে একই আকারের block-এ ভাগ করা হয়, যেগুলোকে Pages বলা হয়।
Process execute হওয়ার সময় এর pages available frame-এ load করা হয়। Paging efficient memory utilization এবং virtual memory support করতে সাহায্য করে।
Page Table
Page Table হলো একটি data structure যা operating system দ্বারা maintain করা হয় এবং logical address (page) ও physical address (frame)-এর mapping সংরক্ষণ করে।
Operating system page table ব্যবহার করে নির্ধারণ করে pageটি physical memory-এর কোন স্থানে রয়েছে।
Page Fault
Page Fault তখন ঘটে যখন কোনো process এমন একটি page access করতে চায় যা বর্তমানে physical memory (RAM)-এ নেই।
এই অবস্থায়:
- Operating system page table পরীক্ষা করে।
- প্রয়োজনীয় page hard disk থেকে RAM-এ load করা হয়।
- Page table update করা হয়।
- এরপর CPU পুনরায় execution চালিয়ে যায়।
A Page Replacement Algorithm is a technique used by the operating system to decide which page should be removed from physical memory (RAM) when a new page needs to be loaded and no free frame is available.
When a process requests a page that is not present in RAM, a Page Fault occurs. In this situation, the operating system must replace an existing page with the required new page.
The main goal of page replacement algorithms is to reduce the number of page faults and improve system performance
Examples of Page Replacement Algorithms
FIFO (First-In-First-Out) Page Replacement
In FIFO, the page that entered RAM first is removed first. It is simple and easy to implement.
LRU (Least Recently Used) Page Replacement
In LRU, the page that has not been used for the longest time is replaced. It gives better performance than FIFO in many cases.
LFU (Least Frequently Used) Page Replacement
In LFU, the page with the lowest usage frequency is removed. Frequently used pages are kept in memory.
Optimal Page Replacement
In Optimal algorithm, the page that will not be used for the longest future time is replaced.It produces the minimum number of page faults.
Page Replacement Algorithm হলো একটি technique যা operating system ব্যবহার করে নির্ধারণ করতে কোন page-টি physical memory (RAM) থেকে সরানো হবে, যখন নতুন page load করার জন্য কোনো free frame available থাকে না।
যখন কোনো process এমন page access করতে চায় যা RAM-এ নেই, তখন Page Fault ঘটে। এই অবস্থায় operating system-কে পুরোনো কোনো page remove করে নতুন page load করতে হয়।
Page replacement algorithm-এর মূল উদ্দেশ্য হলো page fault কমানো এবং system performance উন্নত করা।
Page Replacement Algorithm-এর উদাহরণ
FIFO (First-In-First-Out) Page Replacement
FIFO-তে যে page প্রথম RAM-এ প্রবেশ করে, সেটি প্রথম remove করা হয়। এটি simple এবং implement করা সহজ।
LRU (Least Recently Used) Page Replacement
LRU-তে যে page দীর্ঘ সময় ব্যবহার হয়নি সেটি replace করা হয়।অনেক ক্ষেত্রে এটি FIFO-এর তুলনায় ভালো performance দেয়।
LFU (Least Frequently Used) Page Replacement
LFU-তে সবচেয়ে কম ব্যবহৃত page remove করা হয়।যেসব page বেশি ব্যবহৃত হয় সেগুলো memory-তে রাখা হয়।
Optimal Page Replacement
Optimal algorithm-এ ভবিষ্যতে দীর্ঘ সময় ব্যবহার হবে না এমন page replace করা হয়।
এটি সর্বনিম্ন page fault তৈরি করে।

- Initially, all memory slots are empty. So when pages 1, 3, and 0 arrive, they are loaded into the empty slots. Therefore, 3 Page Faults occur.
- When page 3 arrives again, it is already present in memory. Therefore, 0 Page Fault occurs.
- Then page 5 arrives. Since it is not available in memory, it replaces the oldest page, which is page 1. Therefore, 1 Page Fault occurs.
- Next, page 6 arrives. It is also not available in memory, so it replaces the oldest page, which is page 3. Therefore, 1 Page Fault occurs.
- Finally, page 3 arrives again. Since it is not present in memory, it replaces page 0. Therefore, 1 Page Fault occurs.
- শুরুতে সব memory slot খালি থাকে। তাই যখন page 1, 3 এবং 0 আসে, তখন সেগুলো empty slot-এ load করা হয়। ফলে 3টি Page Fault ঘটে।
- যখন আবার page 3 আসে, তখন এটি আগে থেকেই memory-তে থাকে। তাই 0টি Page Fault ঘটে।
- এরপর page 5 আসে। যেহেতু এটি memory-তে নেই, তাই এটি সবচেয়ে পুরোনো page অর্থাৎ page 1-কে replace করে। ফলে 1টি Page Fault ঘটে।
- এরপর page 6 আসে। এটিও memory-তে নেই, তাই এটি সবচেয়ে পুরোনো page অর্থাৎ page 3-কে replace করে। ফলে 1টি Page Fault ঘটে।
- সবশেষে page 3 আবার আসে। যেহেতু এটি memory-তে নেই, তাই এটি page 0-কে replace করে। ফলে 1টি Page Fault ঘটে।

- Initially, all memory slots are empty. So when pages 7, 0, 1, and 2 arrive, they are loaded into the empty slots. Therefore, 4 Page Faults occur.
- When page 0 arrives again, it is already present in memory. Therefore, 0 Page Fault occurs.
- When page 3 arrives, it is not available in memory. According to the Optimal Page Replacement algorithm, page 7 is replaced because it will not be used for the longest duration in the future. Therefore, 1 Page Fault occurs.
- When page 0 arrives again, it is already available in memory. Therefore, 0 Page Fault occurs.
- When page 4 arrives, it replaces page 1 according to the optimal replacement rule. Therefore, 1 Page Fault occurs.
- For the remaining page references, the required pages are already available in memory. Therefore, 0 Page Fault occurs.
Note:
Optimal Page Replacement gives the best possible result by producing the minimum number of page faults. However, it is not practically possible because the operating system cannot predict future page requests.
This algorithm is mainly used as a benchmark to compare the performance of other page replacement algorithms.
- শুরুতে সব memory slot খালি থাকে। তাই যখন page 7, 0, 1 এবং 2 আসে, তখন সেগুলো empty slot-এ load করা হয়। ফলে 4টি Page Fault ঘটে।
- যখন page 0 আবার আসে, তখন এটি আগে থেকেই memory-তে থাকে। তাই 0টি Page Fault ঘটে।
- যখন page 3 আসে, তখন এটি memory-তে available থাকে না। Optimal Page Replacement algorithm অনুযায়ী page 7 replace করা হয়, কারণ ভবিষ্যতে এটি সবচেয়ে দীর্ঘ সময় ব্যবহার হবে না। ফলে 1টি Page Fault ঘটে।
- যখন page 0 আবার আসে, তখন এটি আগে থেকেই memory-তে available থাকে। তাই 0টি Page Fault ঘটে।
- যখন page 4 আসে, তখন optimal replacement rule অনুযায়ী এটি page 1-কে replace করে। ফলে 1টি Page Fault ঘটে।
- পরবর্তী page reference-গুলোর জন্য প্রয়োজনীয় page আগে থেকেই memory-তে available থাকে। তাই 0টি Page Fault ঘটে।
Note:
Optimal Page Replacement সর্বনিম্ন page fault তৈরি করে সবচেয়ে ভালো result প্রদান করে। তবে বাস্তবে এটি implement করা সম্ভব নয়, কারণ operating system ভবিষ্যতের page request আগে থেকে জানতে পারে না।
এই algorithm মূলত অন্যান্য page replacement algorithm-এর performance তুলনা করার benchmark হিসেবে ব্যবহৃত হয়।

- Initially, all frames are empty. When pages 7, 0, 1, and 2 arrive, they are loaded into the empty frames. Therefore, 4 Page Faults occur.
- When page 0 arrives again, it is already present in memory. Therefore, a Hit occurs and there is 0 Page Fault.
- When page 3 arrives, it is not available in memory. According to the LRU algorithm, page 7 is replaced because it was the least recently used page. Therefore, 1 Page Fault occurs.
- When page 0 arrives again, it is already available in memory. Therefore, a Hit occurs and there is 0 Page Fault.
- When page 4 arrives, it is not available in memory. According to the LRU algorithm, page 1 is replaced because it was the least recently used page. Therefore, 1 Page Fault occurs.
- For the remaining page references (2, 3, 0, 3, 2, 3), all pages are already available in memory. Therefore, only Hits occur and no additional page faults are generated.
Total Page Faults = 6
- শুরুতে সব frame খালি থাকে। যখন page 7, 0, 1 এবং 2 আসে, তখন সেগুলো empty frame-এ load করা হয়। ফলে 4টি Page Fault ঘটে।
- যখন page 0 আবার আসে, তখন এটি আগে থেকেই memory-তে থাকে। তাই একটি Hit ঘটে এবং 0টি Page Fault হয়।
- যখন page 3 আসে, তখন এটি memory-তে available থাকে না। LRU algorithm অনুযায়ী page 7 replace করা হয়, কারণ এটি সবচেয়ে দীর্ঘ সময় ব্যবহার হয়নি। ফলে 1টি Page Fault ঘটে।
- যখন page 0 আবার আসে, তখন এটি আগে থেকেই memory-তে available থাকে। তাই একটি Hit ঘটে এবং 0টি Page Fault হয়।
- যখন page 4 আসে, তখন এটি memory-তে available থাকে না। LRU algorithm অনুযায়ী page 1 replace করা হয়, কারণ এটি সবচেয়ে কম recently used page ছিল। ফলে 1টি Page Fault ঘটে।
- পরবর্তী page reference (2, 3, 0, 3, 2, 3)-গুলোর জন্য সব page আগে থেকেই memory-তে available থাকে। তাই শুধুমাত্র Hit ঘটে এবং নতুন কোনো page fault হয় না।
মোট Page Fault = 6
Previous Job QnS on Operating Systrem
- ☆1Operating SystemProcess Scheduling Algorithm
A system has three processes with the following arrival times and CPU burst times:
Process Arrival Time (ms) Burst Time (ms) P1 0 5 P2 1 3 P3 2 2 Using the First-Come, First-Served (FCFS) CPU scheduling algorithm, calculate the average waiting time and the average turnaround time.
CB, O(IT-24), 26 | Officer (IT)
- ☆2Operating SystemProcess Scheduling AlgorithmOperating System Round Robin: (Quantum number =3), 4 job (job1, job2, job3, job4), Arrival time: 0,2,8,5; Burst time: 9, 7, 2, 3. What is the average waiting time?CB, AE(IT)/AHME/SO, 21 | AME/ANE/AE
Gantt Chart:


Average Time: 25/4 = 6.25
- ☆3Operating SystemProcess Scheduling AlgorithmOperating System (OS) scheduling is the key concept of multiprogramming. List and briefly define the major types of OS scheduling.CB, O(IT), 20 | Officer (IT)
Major Types of Operating System (OS) Scheduling
Answer:
OS Scheduling is the process of selecting which process will execute on the CPU. It is a key concept of Multiprogramming because it improves CPU utilization and system performance.
Major Types of OS Scheduling
Scheduling Type Definition Long-Term Scheduler (Job Scheduler) Selects jobs from secondary storage and loads them into main memory for execution. Short-Term Scheduler (CPU Scheduler) Selects a process from the ready queue and allocates the CPU to it. Medium-Term Scheduler Temporarily removes (swaps out) processes from memory and later brings them back to improve system performance. The Long-Term Scheduler controls the degree of multiprogramming, the Short-Term Scheduler allocates the CPU, and the Medium-Term Scheduler manages memory efficiently through swapping.
- ☆4Operating SystemProcess Scheduling AlgorithmCalculate The Average Waiting Time of SJF scheduling algorithm.
Process Burst Time Arrival Time P1 10 3 P2 1 1 P3 2 3 P4 1 4 P5 5 2
(i) Average waiting time for FCFS
(ii) Preemptive SJF
(iii) Round Robin (Quantum time: 3) scheduling algorithmJanata, ASA, 21 | AME/ANE/AE


- ☆5Operating SystemProcess Scheduling Algorithm
১ (গ) নিচের সারণীটি দেখুন-
Process
Burst Time (milli second)
Priority
P1
15
3
P2
2
1
P3
4
3
P4
2
4
P5
8
2
সমস্থ process একই সাথে 0 সময়ে এসে পৌঁছে।
- i) FCFS এবং SJF Scheduling algorithm ব্যবহার করে Gantt Chart এর মাধ্যমে process গুলোর execution দেখান।
- ii) উপরের উভয় algorithm এর জন্য প্রত্যেকটি process এর turnaround সময় নির্ণয় করুন।
BPSC_MoHA_AP, 26 | Assistant Programmer (BPSC) - ☆6Operating SystemProcess Scheduling Algorithm
Job arrival time and execution time of Operating system tasks table is given, find out
Average waiting timeJob Arrival Time Execution Time A 0 10 B 3 7 C 5 3
(i) FCFS
(ii) Preemptive SJF
(iii) Round Robin (Quantum time: 3)Rupali, ANE, 21 |(i) FCFS:
(ii)SJF

(iii) Round Robin:
- ☆7Operating SystemWhy is a Circular Queue preferred over a Linear Queue in many operating systems? Explain with one example.Combined Bank, SO(IT-24), 26 | Senior Officer (IT)
A Circular Queue is preferred over a Linear Queue because it utilizes memory more efficiently. In a Linear Queue, once the Rear reaches the last position, no new element can be inserted even if there are empty spaces at the beginning of the queue. A Circular Queue overcomes this limitation by connecting the last position to the first, allowing the freed spaces to be reused.
Advantages of Circular Queue
• Efficient utilization of memory.
• Eliminates wasted space created after deletion.
• No need to shift elements after deletion.
• Faster insertion and deletion operations.
• Widely used in Operating Systems for scheduling and buffering.Example
In CPU Scheduling using the Round Robin Algorithm, processes are stored in a Circular Queue. After a process completes its allocated time slice (Time Quantum), it is moved to the rear of the queue, and the next process gets the CPU. This continues until all processes are executed.
Circular Queue সাধারণ Linear Queue-এর তুলনায় অধিক কার্যকর, কারণ এটি Memory দক্ষতার সাথে ব্যবহার করে। Linear Queue-এ Rear শেষ অবস্থানে পৌঁছে গেলে নতুন Element Insert করা যায় না, যদিও Queue-এর শুরুতে Delete হওয়ার কারণে খালি স্থান থাকতে পারে। Circular Queue-এ শেষ Position প্রথম Position-এর সাথে যুক্ত থাকে, ফলে খালি স্থান পুনরায় ব্যবহার করা যায়।
Circular Queue-এর সুবিধা
• Memory Utilization বেশি কার্যকর।
• Delete-এর পর তৈরি হওয়া খালি স্থান পুনরায় ব্যবহার করা যায়।
• Element Shift করার প্রয়োজন হয় না।
• Enqueue এবং Dequeue Operation দ্রুত সম্পন্ন হয়।
• Operating System-এ CPU Scheduling এবং Buffer Management-এ ব্যাপকভাবে ব্যবহৃত হয়।উদাহরণ
Round Robin CPU Scheduling Algorithm-এ সকল Process একটি Circular Queue-তে রাখা হয়। একটি Process নির্ধারিত Time Quantum শেষ করলে সেটিকে Queue-এর শেষে পাঠানো হয় এবং পরবর্তী Process CPU পায়। এভাবে সব Process পর্যায়ক্রমে Execute হয়।
- ☆8Operating SystemExplain 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 ব্যবহার করতে পারে। - ☆9Operating SystemYou friend device is slow performing so what should you take step in your task managerSonali Bank, ADA, 26 | ADA
Steps to Fix Slow Device Using Task Manager
- Open Task Manager: Press Ctrl + Shift + Esc.
- Check CPU Usage: Identify processes using high CPU.
- Check Memory (RAM): Find apps consuming too much memory.
- End Unnecessary Tasks: Select heavy apps → click End Task.
- Startup Programs: Go to Startup tab → disable unnecessary apps.
- Disk Usage: Check if disk is 100% → stop heavy processes.
- Background Apps: Close unused background applications.
Task Manager ব্যবহার করে Slow Device ঠিক করার ধাপ
- Task Manager খুলুন: Ctrl + Shift + Esc চাপুন।
- CPU Usage দেখুন: কোন process বেশি CPU নিচ্ছে তা খুঁজুন।
- Memory (RAM) দেখুন: কোন app বেশি RAM ব্যবহার করছে তা দেখুন।
- Unnecessary Task বন্ধ করুন: heavy app select করে End Task দিন।
- Startup Program: Startup tab থেকে অপ্রয়োজনীয় app disable করুন।
- Disk Usage: যদি 100% হয়, heavy process বন্ধ করুন।
- Background App: অপ্রয়োজনীয় background app বন্ধ করুন।
- ☆10Operating SystemBasicDifferentiate between Logical Address and Physical Address in context of Operating System.Combined Bank, AE(IT)/AME, 26 | AME/ANE/AE
Difference Between Logical Address and Physical Address
- Definition: Logical Address is generated by CPU; Physical Address is the actual location in memory (RAM).
- Visibility: Logical Address is visible to the user/program; Physical Address is not directly visible to the user.
- Generation: Logical Address is created during program execution; Physical Address is obtained after address translation.
- Translation: Logical Address is converted to Physical Address using MMU (Memory Management Unit).
- Address Space: Logical Address Space is virtual; Physical Address Space is real memory.
- Access: CPU uses Logical Address; Memory hardware uses Physical Address.
Logical Address এবং Physical Address এর পার্থক্য
- সংজ্ঞা: Logical Address CPU তৈরি করে; Physical Address হলো RAM-এর আসল location।
- দৃশ্যমানতা: Logical Address program/user দেখতে পারে; Physical Address সরাসরি দেখা যায় না।
- উৎপত্তি: Logical Address program চলাকালে তৈরি হয়; Physical Address translation এর পরে পাওয়া যায়।
- রূপান্তর: Logical Address কে Physical Address-এ রূপান্তর করে MMU (Memory Management Unit)।
- Address Space: Logical Address Space virtual; Physical Address Space বাস্তব memory।
- ব্যবহার: CPU Logical Address ব্যবহার করে; Memory hardware Physical Address ব্যবহার করে।
- ☆11Operating SystemBasicDefine 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 পায়
- ☆12Operating SystemVirtual MemoryWhat is Swapping from virtual memory in the primary memory.CB, AE(IT)/AHME/SO, 21 | AME/ANE/AE
Swapping in Operating System
Swapping is a memory management technique used by an operating system to efficiently manage the limited primary memory (RAM) and the larger but slower secondary memory such as a hard disk or SSD.
What is Swapping?
Swapping is the process of moving entire processes between primary memory (RAM) and secondary memory. When the RAM becomes full and the system needs memory to run active programs, the operating system moves some inactive or low-priority processes from RAM to secondary memory. This process is called swapping out.Later, when the swapped-out process is required again, the operating system brings the process back into RAM from secondary memory. This process is called swapping in.
Through this back-and-forth movement of processes between RAM and secondary memory, the operating system can run more processes than the physical memory can normally support.

Operating System-এ Swapping
Swapping হলো একটি memory management technique যা operating system ব্যবহার করে সীমিত primary memory (RAM) এবং তুলনামূলক বড় কিন্তু ধীর secondary memory (hard disk বা SSD) দক্ষভাবে পরিচালনা করতে।
Swapping কী?
Swapping হলো এমন একটি প্রক্রিয়া যেখানে সম্পূর্ণ process-কে primary memory (RAM) এবং secondary memory-এর মধ্যে স্থানান্তর করা হয়। যখন RAM পূর্ণ হয়ে যায় এবং নতুন program চালানোর জন্য memory প্রয়োজন হয়, তখন operating system কিছু inactive বা কম গুরুত্বপূর্ণ process-কে RAM থেকে secondary memory-তে সরিয়ে দেয়। এই প্রক্রিয়াকে swapping out বলা হয়।পরে যখন সেই process আবার প্রয়োজন হয়, তখন operating system সেটিকে secondary memory থেকে আবার RAM-এ নিয়ে আসে। এই প্রক্রিয়াকে swapping in বলা হয়।
এইভাবে RAM এবং secondary memory-এর মধ্যে process আদান-প্রদানের মাধ্যমে operating system একসাথে অনেকগুলো process পরিচালনা করতে পারে।

- ☆13Operating SystemPagingConsider a machine with 64 MB physical memory and a 32 bit virtual address space. If the page size is 4 KB, what is the approximate size of the page table.CB, AE(IT)/AHME/SO, 21 | AME/ANE/AE
Physical Address Space = 64MB = \(2^{26}\text{B}\)
Virtual Address = 32-bits, \(\therefore\) Virtual Address Space = \(2^{32}\text{B}\)
Page Size = 4KB = \(2^{12}\text{B}\)
Number of pages = \(\frac{2^{32}}{2^{12}} = 2^{20}\) pages.
Number of frames = \(\frac{2^{26}}{2^{12}} = 2^{14}\) frames.
\(\therefore\) Page Table Size = \(2^{20} \times 14\text{-bits} \approx 2^{20} \times 16\text{-bits} \approx 2^{20} \times 2\text{B} = 2\text{MB}\).
Physical Address Space = 64MB = \(2^{26}\text{B}\)
Virtual Address = 32-bits, \(\therefore\) Virtual Address Space = \(2^{32}\text{B}\)
Page Size = 4KB = \(2^{12}\text{B}\)
Number of pages = \(\frac{2^{32}}{2^{12}} = 2^{20}\) pages.
Number of frames = \(\frac{2^{26}}{2^{12}} = 2^{14}\) frames.
\(\therefore\) Page Table Size = \(2^{20} \times 14\text{-bits} \approx 2^{20} \times 16\text{-bits} \approx 2^{20} \times 2\text{B} = 2\text{MB}\).
- ☆14Operating SystemPagingConsider a logical address space of 512 pages, each of 2-KB page size, mapped onto a physical memory containing 128 frames.
a. How many bits are required in the logical address?
b. How many bits are required in the physical address? (10 Marks)Combined Bank, SO-IT, 25 | Senior Officer (IT)Given
Logical address space = 512 pages
Page size = 2 KB = 2048 bytes
Physical memory = 128 framesa) Bits required in the Logical Address
Number of pages = 512 = 29 → Page number bits = 9 bits
Page size = 2048 bytes = 211 → Offset bits = 11 bits
So, Logical address bits = Page number bits + Offset bits = 9 + 11 = 20 bitsb) Bits required in the Physical Address
Number of frames = 128 = 27 → Frame number bits = 7 bits
Offset remains same = 11 bits
So, Physical address bits = Frame number bits + Offset bits = 7 + 11 = 18 bitsপ্রদত্ত তথ্য
Logical address space = 512 pages
Page size = 2 KB = 2048 bytes
Physical memory = 128 framesa) Logical Address এর জন্য কত bit লাগবে
Page সংখ্যা = 512 = 29 → Page number এর জন্য লাগবে 9 bit
Page size = 2048 bytes = 211 → Offset এর জন্য লাগবে 11 bit
সুতরাং Logical address bits = 9 + 11 = 20 bitb) Physical Address এর জন্য কত bit লাগবে
Frame সংখ্যা = 128 = 27 → Frame number এর জন্য লাগবে 7 bit
Offset একই থাকবে = 11 bit
সুতরাং Physical address bits = 7 + 11 = 18 bit
- ☆15Operating SystemThreadTwo separate threads are initialized with the exact same instance of CounterSubsystem and run concurrently to completion. State definitively whether the final value of transactionCounter is guaranteed to be exactly 2000. Name the specific multithreading hazard that occurs here and explain the low-level mechanical steps that cause this behavior.
class CounterSubsystem implements Runnable {
public int transactionCounter = 0;
@Override
public void run() {
for (int i = 0; i < 1000; i++) {
transactionCounter++;
}
}
}Combined Bank, AP-23, 26 | Assistant ProgrammerMultithreading Analysis: CounterSubsystem
Is the final value guaranteed to be 2000?
No, the final value of transactionCounter is NOT guaranteed to be exactly 2000. The actual result could be any value between 1000 and 2000, but it will most likely be less than 2000.
Specific Multithreading Hazard
The hazard is a Race Condition, specifically a Data Race or Read-Modify-Write Race Condition. It occurs because multiple threads access and modify the same shared variable without synchronization.
Low-Level Execution Steps
The statement transactionCounter++ is not atomic. It breaks into three steps:
- READ: Load value from memory into CPU register
- MODIFY: Increment the value in the register
- WRITE: Store updated value back to memory
Because both threads execute these steps concurrently, their operations can interleave, causing lost updates.
Lost Update Example:
Time Step Thread 1 Thread 2 Memory Value 1 READ: 0 0 2 READ: 0 0 3 MODIFY: 1 0 4 MODIFY: 1 0 5 WRITE: 1 1 6 WRITE: 1 1 Both threads overwrite each other’s updates, so increments are lost. Repeated many times, this reduces the final count below 2000.
How to Fix It
- synchronized: Protect increment using a lock to ensure mutual exclusion
- AtomicInteger: Use
incrementAndGet()for atomic updates - volatile: Not sufficient because it does not make compound operations atomic
Multithreading Analysis: CounterSubsystem
Final value 2000 হওয়া guaranteed কিনা?
No, transactionCounter-এর final value exactly 2000 হওয়া guaranteed নয়। Actual result 1000 থেকে 2000-এর মধ্যে যেকোনো value হতে পারে, তবে সাধারণত 2000-এর কম হবে।
Specific Multithreading Hazard
Hazard হলো Race Condition, বিশেষ করে Data Race বা Read-Modify-Write Race Condition। এটি ঘটে যখন একাধিক thread একই shared variable synchronization ছাড়া modify করে।
Low-Level Execution Steps
transactionCounter++ atomic operation নয়। এটি তিনটি step-এ ভাগ হয়:
- READ: memory থেকে value CPU register-এ আনা
- MODIFY: value 1 বাড়ানো
- WRITE: updated value memory-তে লেখা
দুটি thread একসাথে run করলে এই steps interleave হয়ে lost update তৈরি হয়।
Lost Update Example:
Time Step Thread 1 Thread 2 Memory Value 1 READ: 0 0 2 READ: 0 0 3 MODIFY: 1 0 4 MODIFY: 1 0 5 WRITE: 1 1 6 WRITE: 1 1 একই update overwrite হওয়ায় কিছু increment হারিয়ে যায়, ফলে final value 2000-এর কম হয়।
Fix করার উপায়
- synchronized: lock ব্যবহার করে one-thread-at-a-time update নিশ্চিত করা
- AtomicInteger:
incrementAndGet()ব্যবহার করা - volatile: যথেষ্ট নয় কারণ এটি atomicity দেয় না
- ☆16Operating SystemTLBA system utilizes a 32-bit logical address space and a page size of 220 bytes. If each entry (block) in the Translation Lookaside Buffer (TLB) requires 6 bytes, calculate the total memory required for the TLB to map the entire logical address space.Combined Bank, AP-23, 26 | Assistant Programmer
Given:
- Logical address space = 32-bit
- Page size = 220 bytes
- TLB entry size = 6 bytes per entry
Step 1: Calculate Total Logical Address Space
A 32-bit address can reference 232 unique bytes.
Total logical address space = 232 bytesStep 2: Calculate Number of Pages
Number of pages = Total address space ÷ Page size
Number of pages = 232 ÷ 220 = 2(32 − 20) = 212 = 4096 pagesStep 3: Calculate Total TLB Memory
Each page requires one TLB entry to map the entire logical address space.
Total TLB memory = Number of pages × Entry size
Total TLB memory = 4096 × 6 = 24576 bytesIn kilobytes: 24576 ÷ 1024 = 24 KB
- ☆17Operating SystemBootingWrite about Boot Process.Pubali, JHE, 23 |
The Boot Process is the sequence of steps a computer follows to start up after it is powered on or restarted. During this process, the hardware is initialized, the operating system is loaded into memory, and the computer becomes ready for use.
Steps of the Boot Process
1. Power On: The user turns on the computer, and the CPU begins executing instructions stored in the firmware (BIOS or UEFI).
2. POST (Power-On Self-Test): The BIOS/UEFI checks hardware components such as RAM, CPU, keyboard, storage devices, and other peripherals to ensure they are functioning correctly.
3. Boot Loader Execution: The Boot Loader (e.g., GRUB, Windows Boot Manager) is loaded from the bootable storage device.
4. Operating System Loading: The Boot Loader loads the Operating System Kernel into the main memory (RAM).
5. Kernel Initialization: The Kernel initializes device drivers, memory management, file systems, and other essential system services.
6. User Login: The operating system starts system services and displays the login screen or desktop, making the computer ready for use.
Boot Process হলো Computer চালু (Power On) বা Restart হওয়ার পর ধাপে ধাপে সম্পন্ন হওয়া একটি Process, যার মাধ্যমে Hardware Initialize হয়, Operating System (OS) Memory-তে Load হয় এবং Computer ব্যবহার উপযোগী হয়ে ওঠে।
Boot Process-এর ধাপসমূহ
১. Power On: User Computer চালু করলে CPU Firmware (BIOS বা UEFI)-এ সংরক্ষিত Instruction Execute করা শুরু করে।
২. POST (Power-On Self-Test): BIOS/UEFI RAM, CPU, Keyboard, Storage Device এবং অন্যান্য Hardware সঠিকভাবে কাজ করছে কিনা তা পরীক্ষা করে।
৩. Boot Loader Execution: Bootable Storage Device থেকে Boot Loader (যেমন: GRUB বা Windows Boot Manager) Load হয়।
৪. Operating System Loading: Boot Loader Operating System Kernel-কে RAM-এ Load করে।
৫. Kernel Initialization: Kernel Device Driver, Memory Management, File System এবং অন্যান্য System Service Initialize করে।
৬. User Login: Operating System প্রয়োজনীয় Service চালু করে Login Screen বা Desktop প্রদর্শন করে এবং Computer ব্যবহারের জন্য প্রস্তুত হয়।
- ☆18Operating SystemBootingDescribe the booting process in windows system.Pubali, HE, 23 | Bank
Booting Process in Windows System
The booting process in a Windows system is the sequence of steps that starts when the computer is powered on and ends when the Windows operating system is fully loaded and ready for use.
Step 1: Power On and POST
When the system is powered on, BIOS or UEFI performs POST (Power-On Self Test) to check hardware components such as CPU, RAM, keyboard, and storage devices.
Step 2: BIOS/UEFI Initialization
After POST, BIOS or UEFI initializes hardware components and identifies the bootable device based on the boot order configuration.
Step 3: Boot Loader Execution
The boot loader (Windows Boot Manager – bootmgr) is loaded from the boot device, which locates and prepares the Windows operating system to start.
Step 4: Windows Kernel Loading
The Windows kernel (ntoskrnl.exe) is loaded into memory along with essential drivers required for system operation.
Step 5: System Initialization
Windows initializes system services, device drivers, and registry settings needed for system functionality.
Step 6: User Logon
The Windows logon screen appears, allowing the user to enter credentials and access the system.
Step 7: Desktop Ready
After successful login, the Windows desktop is displayed and the system is ready for use.
Windows System-এ Booting Process
Windows system-এর booting process হলো computer চালু হওয়ার পর থেকে Windows operating system সম্পূর্ণভাবে load হওয়া পর্যন্ত ধাপে ধাপে সম্পন্ন হওয়া প্রক্রিয়া।
Step 1: Power On ও POST
System চালু হলে BIOS বা UEFI POST (Power-On Self Test) চালায়, যেখানে CPU, RAM, keyboard ও storage device পরীক্ষা করা হয়।
Step 2: BIOS/UEFI Initialization
POST শেষ হলে BIOS বা UEFI hardware initialize করে এবং boot order অনুযায়ী bootable device নির্বাচন করে।
Step 3: Boot Loader চালু
Boot device থেকে Windows Boot Manager (bootmgr) load হয়, যা Windows চালু করার প্রস্তুতি নেয়।
Step 4: Windows Kernel Load
Windows kernel (ntoskrnl.exe) এবং প্রয়োজনীয় system driver memory-তে load হয়।
Step 5: System Initialization
Windows system service, device driver এবং registry setting initialize করে।
Step 6: User Logon
User-এর সামনে Windows logon screen আসে এবং credential দেওয়ার সুযোগ দেয়।
Step 7: Desktop Ready
Login সফল হলে Windows desktop প্রদর্শিত হয় এবং system ব্যবহারযোগ্য হয়।
- ☆19Operating SystemThreadingWhat hyper-threading is and its uses?Pubali, JHE, 23 |
Hyper-Threading (HT) is a technology developed by Intel that allows a single physical CPU core to function as two logical (virtual) cores. This enables the processor to execute multiple threads simultaneously, improving CPU utilization and overall system performance.
How Does Hyper-Threading Work?
In Hyper-Threading, each physical CPU core appears as two logical processors to the Operating System. When one thread is waiting for data or resources, the CPU can execute another thread, reducing idle time and increasing efficiency.
Uses of Hyper-Threading
• Improves multitasking performance by running multiple threads simultaneously.
• Increases CPU utilization and overall system efficiency.
• Enhances the performance of multi-threaded applications such as video editing, 3D rendering, and software development.
• Improves virtualization by allowing more virtual machines to run efficiently.
• Reduces CPU idle time by executing another thread while one thread is waiting.
Hyper-Threading (HT) হলো Intel কর্তৃক উন্নয়নকৃত একটি Technology, যা একটি Physical CPU Core-কে দুটি Logical (Virtual) Core হিসেবে কাজ করার সুযোগ দেয়। এর ফলে Processor একই সময়ে একাধিক Thread Execute করতে পারে এবং System-এর Performance বৃদ্ধি পায়।
Hyper-Threading কীভাবে কাজ করে?
Hyper-Threading-এ প্রতিটি Physical Core, Operating System-এর কাছে দুটি Logical Processor হিসেবে দেখা যায়। যখন একটি Thread Data বা Resource-এর জন্য অপেক্ষা করে, তখন CPU অন্য একটি Thread Execute করে। এতে CPU-এর Idle Time কমে এবং Efficiency বৃদ্ধি পায়।
Hyper-Threading-এর ব্যবহার
• একই সময়ে একাধিক Thread চালিয়ে Multitasking Performance বৃদ্ধি করে।
• CPU-এর Resource আরও দক্ষতার সাথে ব্যবহার করে।
• Video Editing, 3D Rendering, Software Development এবং অন্যান্য Multi-threaded Application-এর Performance উন্নত করে।
• Virtualization-এ একাধিক Virtual Machine আরও দক্ষভাবে চালাতে সহায়তা করে।
• একটি Thread অপেক্ষমাণ থাকলে অন্য Thread Execute করে CPU-এর Idle Time কমায়।
- ☆20Operating SystemDeadlockWhat is Deadlock? Explain two situations where deadlock condition occurs.Janata, ASA, 21 | AME/ANE/AE
Deadlock is a situation in an Operating System where two or more processes are unable to continue execution because each process is waiting for a resource that is held by another process.
Two Situations Where Deadlock Occurs
- Mutual Exclusion: A resource can be used by only one process at a time. If another process requests the same resource, it must wait until the resource is released.
- Circular Wait: Deadlock occurs when a group of processes form a circular chain where each process is waiting for a resource held by the next process in the chain.
- ☆21Operating SystemDeadlockBriefly explain Circular Wait. In a Resource Allocation Graph (RAG), if a cycle exists, does it absolutely guarantee that a Deadlock has occurred? Explain briefly.CB, AME/AE(IT-23), 26 | AME/ANE/AE
Circular Wait
- Circular wait is one of the necessary conditions for deadlock.
- It occurs when a group of processes are waiting for resources in a circular chain.
- In this situation, each process holds at least one resource and waits for another resource held by the next process in the cycle.
Example:
- Process P1 holds Resource R1 and waits for R2.
- Process P2 holds Resource R2 and waits for R3.
- Process P3 holds Resource R3 and waits for R1.
This creates a circular waiting condition.

Cycle in Resource Allocation Graph (RAG)
If a cycle exists in a Resource Allocation Graph, it does not always guarantee deadlock.
- If each resource type has only one instance, then a cycle definitely indicates deadlock.
- If resource types have multiple instances, then a cycle may exist without deadlock.
So, a cycle is:
- A necessary condition for deadlock
- But not always a sufficient condition
Deadlock Detection using Resource Allocation Graph
To detect deadlock using Resource Allocation Graph (RAG), we follow these steps −
- If RAG contains no cycles, then there is no deadlock in the system.
- If RAG is of single instance resources and it contains a cycle, then there is a deadlock in the system.
- If RAG is of multiple instance resources and it contains a cycle, then deadlock may or may not exist. To check for deadlock, we need convert multiple instance RAG to single instance RAG, by treating each instance of a resource as a separate resource type.

In the graph:
- Resource R1 has only one instance.
- Resource R2 has two instances.
- P1 is holding R1 and requesting R2.
- P2 is holding one instance of R2 and requesting R1.
- P3 is using another instance of R2.
A cycle exists in the graph: P1 → R2 → P2 → R1 → P1
But this graph does not indicate deadlock.
Reason:
Resource R2 has multiple instances. One instance of R2 is currently allocated to P3.
If P3 finishes its work and releases R2, then:
- P1 can obtain R2 and complete execution.
- After P1 completes, it releases R1.
- Then P2 can obtain R1 and continue execution.
Since the processes can still proceed and resources can eventually be released, the system is not permanently blocked.
প্রশ্ন: Circular Wait সংক্ষেপে ব্যাখ্যা কর। Resource Allocation Graph (RAG)-এ cycle থাকলে কি নিশ্চিতভাবে Deadlock হয়েছে বোঝায়? সংক্ষেপে ব্যাখ্যা কর।
Circular Wait
- Circular wait হলো deadlock-এর একটি প্রয়োজনীয় শর্ত।
- এটি তখন ঘটে যখন একাধিক process একটি circular chain আকারে resource-এর জন্য অপেক্ষা করে।
- এখানে প্রতিটি process অন্তত একটি resource ধরে রাখে এবং পরবর্তী process-এর কাছে থাকা অন্য resource-এর জন্য অপেক্ষা করে।
উদাহরণ:
- Process P1 Resource R1 ধরে রেখে R2-এর জন্য অপেক্ষা করছে।
- Process P2 Resource R2 ধরে রেখে R3-এর জন্য অপেক্ষা করছে।
- Process P3 Resource R3 ধরে রেখে R1-এর জন্য অপেক্ষা করছে।
এভাবে একটি circular waiting condition তৈরি হয়।

Resource Allocation Graph (RAG)-এ Cycle
RAG-এ cycle থাকলেই সবসময় deadlock হয়েছে এমন নয়।
- যদি প্রতিটি resource type-এর শুধুমাত্র একটি instance থাকে, তাহলে cycle থাকলে নিশ্চিত deadlock হয়েছে।
- কিন্তু resource type-এর একাধিক instance থাকলে cycle থাকলেও deadlock নাও হতে পারে।
অতএব cycle হলো:
- Deadlock-এর জন্য একটি necessary condition
- কিন্তু সবসময় sufficient condition নয়

Graph-এ:
- Resource R1-এর একটি instance রয়েছে।
- Resource R2-এর দুটি instance রয়েছে।
- P1, R1 ধরে রেখে R2-এর জন্য অপেক্ষা করছে।
- P2, R2-এর একটি instance ধরে রেখে R1-এর জন্য অপেক্ষা করছে।
- P3, R2-এর অন্য instance ব্যবহার করছে।
Graph-এ একটি cycle রয়েছে:
P1 → R2 → P2 → R1 → P1
কিন্তু এই graph-এ deadlock নেই।
কারণ:
Resource R2-এর একাধিক instance রয়েছে। বর্তমানে R2-এর একটি instance P3 ব্যবহার করছে।
যদি P3 তার কাজ শেষ করে R2 release করে, তাহলে:
- P1, R2 পেয়ে execution সম্পন্ন করতে পারবে।
- P1 কাজ শেষ করলে R1 release করবে।
- তারপর P2, R1 পেয়ে execution চালিয়ে যেতে পারবে।
অর্থাৎ process-গুলো পরবর্তীতে execution চালিয়ে যেতে পারছে, তাই system permanently blocked নয়।
- ☆22Operating SystemDeadlockConsider the following snapshot of a system where maximum instance of A, B, C and D are 3, 14, 12 and 12.
Answer the following Question using the Bankers algorithm,
a) Calculate the need matrix from the above table?
b) Is the system in the safe state? Find out the safe sequence if no, justify the reason.BB, AD(ICT), 25 | Bangladesh Banka) answer:The Need matrix is calculated as: Need = Max - Allocation For each process, we subtract the Allocation from the Max to get the Need Matrix.

b) answer:Step-by-step checking for our system:
- P0: Needs [0, 0, 0, 0] ≤ Available [1, 5, 2, 0] → yes, so finish P0.
- Update Available by adding P0's allocation: [1, 5, 2, 0] + [0, 0, 1, 2] = [1, 5, 3, 2]
- P1: Needs [0, 7, 5, 0] ≤ Available [1, 5, 3, 2] → no, cannot finish yet.
- P2: Needs [1, 0, 0, 2] ≤ Available [1, 5, 3, 2] → yes, finish P2.
- Update Available : [1, 5, 3, 2] + [1, 3, 5, 4] = [2, 8, 8, 6]
- P3: Needs [0, 0, 2, 0] ≤ Available [2, 8, 8, 6] → yes, finish P3.
- Update Available : [2, 8, 8, 6] + [0, 6, 3, 2] = [2, 14, 11, 8]
- P4: Needs [0, 6, 4, 2] ≤ Available [2, 14, 11, 8] → yes, finish P4.
- Update Available : [2, 14, 11, 8] + [0, 0, 1, 4] = [2, 14, 12, 12]
- P1 (rechecked): Needs [0, 7, 5, 0] ≤ Available [2, 14, 12, 12] → yes, finish P1.
- Update Available : [2, 14, 12, 12] + [1, 0, 0, 0] = [3, 14, 12, 12]
Since all processes can finish in this order, the system is in a safe state.
Safe sequence: <P0, P2, P3, P4, P1>
🎥 Video Solution: Deadlock Handling (Deadlock Avoidance - Banker's Algorithm) - ☆23Operating SystemDeadlockGive the necessary condition for deadlock occur. Is it possible to have deadlock involving only a single process ? Explain your answer?Combined Bank, O(IT), 24 | Officer (IT)
Deadlock in an operating system occurs when two or more processes are stuck and cannot proceed because they are each waiting for a resource that another process holds. Essentially, the processes are in a "waiting loop," and none can continue because they are all waiting for each other to release resources.
Example: Imagine two people on a narrow staircase. One is going up, and the other is going down. Neither can move because the other person is blocking their path, and neither is willing to back up. They are stuck, waiting for the other to move first, which will never happen.
Necessary condition for occuring deadlock / Coffman Conditions
For a deadlock to happen, four conditions must all be true at the same time. These are called the Coffman conditions, named after the researchers who explained them.
- Mutual Exclusion: A resource can only be used by one process at a time. If a process is using a resource, no other process can use it until the first process releases it.
- Hold and Wait: A process is holding at least one resource and is waiting for additional resources that are currently held by other processes.
- No Preemption: Resources cannot be taken away from a process forcefully. A process can only release resources voluntarily when it is no longer needed.
- Circular Wait: A cycle exists where each process in the cycle is waiting for a resource that the next process holds. For example, Process A is waiting for Process B's resource, Process B is waiting for Process C's resource, and Process C is waiting for Process A's resource.
🎥 Video Solution: Deadlock & its Necessary Condition
✅ Can Deadlock Involve Only a Single Process?
In general, a deadlock cannot occur with only one process. The key characteristic of deadlock is that multiple processes are waiting for each other to release resources. A single process cannot create circular waiting, which is required for deadlock.
- ☆24Operating SystemMemory AllocationIn the given example, let us assume the jobs and the memory requirements as the following: Job1 = 90k, Job2 = 20k, Job350k, Job4=200k. Let the free pace memory allocation blocks be: Block1= 50k, Block2= 100k, Block3=90k, Block4=200k, Block5 50k. Now show Best Fit Method and first fit method memory allocation. [Similar Question but value cannot exactly remember.]Janata, ASA, 21 | AME/ANE/AE
Given:
Jobs: J1 = 90K, J2 = 20K, J3 = 50K, J4 = 200K
Blocks: B1 = 50K, B2 = 100K, B3 = 90K, B4 = 200K, B5 = 50K1) First Fit Method
In First Fit, each job is placed in the first block that is large enough.
Step by step:
J1 = 90K → first block that fits is B2 = 100K
Remaining in B2 = 10KJ2 = 20K → first block that fits is B1 = 50K
Remaining in B1 = 30KJ3 = 50K → first block that fits is B3 = 90K
Remaining in B3 = 40KJ4 = 200K → first block that fits is B4 = 200K
Remaining in B4 = 0KFirst Fit Allocation Table:
Job Size Allocated Block Block Size Unused Space J1 90K B2 100K 10K J2 20K B1 50K 30K J3 50K B3 90K 40K J4 200K B4 200K 0K 2) Best Fit Method
In Best Fit, each job is placed in the smallest block that can hold it.
Step by step:
J1 = 90K → best block is B3 = 90K
Remaining in B3 = 0KJ2 = 20K → best block is B1 = 50K
Remaining in B1 = 30KJ3 = 50K → best block is B5 = 50K
Remaining in B5 = 0KJ4 = 200K → best block is B4 = 200K
Remaining in B4 = 0KBest Fit Allocation Table:
Job Size Allocated Block Block Size Unused Space J1 90K B3 90K 0K J2 20K B1 50K 30K J3 50K B5 50K 0K J4 200K B4 200K 0K Final Answer:
First Fit allocation:
J1 → B2, J2 → B1, J3 → B3, J4 → B4Best Fit allocation:
J1 → B3, J2 → B1, J3 → B5, J4 → B4
- ☆25Operating SystemProcesses and ThreadsExplain the fundamental difference between a Process and a Thread. Provide two distinct advantages of using threads over processes.Combined Bank, AP-22, 26 | Assistant Programmer
Difference between Process and Thread
A process is an independent program in execution with its own memory space, system resources, and execution context. A thread is the smallest unit of execution within a process and shares the same memory and resources with other threads of that process.
Advantages of Threads over Processes
1) Faster Communication: Threads within the same process share memory, making inter-thread communication faster than inter-process communication.
2) Lower Resource Overhead: Threads require less memory and fewer system resources compared to processes, leading to better performance and efficiency.
Process এবং Thread এর মৌলিক পার্থক্য
Process হলো একটি স্বতন্ত্র প্রোগ্রাম যা execution অবস্থায় থাকে এবং যার নিজস্ব memory space ও system resource থাকে। Thread হলো process এর ভেতরে থাকা সবচেয়ে ছোট execution unit, যা একই process এর অন্যান্য thread এর সাথে memory ও resource শেয়ার করে।
Process এর তুলনায় Thread ব্যবহারের সুবিধা
1) দ্রুত Communication: একই process এর thread গুলো memory শেয়ার করায় একে অপরের সাথে খুব দ্রুত data আদান-প্রদান করতে পারে।
2) কম Resource ব্যবহার: Thread process এর তুলনায় কম memory ও system resource ব্যবহার করে, ফলে performance বেশি হয়।
- ☆26Operating SystemProcess SynchronizationExplain the "Producer-Consumer" problem in operating systems. What specific synchronization issue must be solved?Combined Bank, AP-22, 26 | Assistant Programmer
Producer-Consumer Problem
The Producer-Consumer problem is a classic synchronization problem in operating systems. In this problem, one or more producer processes generate data items and place them into a shared buffer, while one or more consumer processes remove and use those data items from the same buffer.
The shared buffer has a limited size, so coordination between producers and consumers is required to ensure correct operation.
Specific Synchronization Issue
The main synchronization issue that must be solved is race condition while accessing the shared buffer. The system must ensure:
• A producer does not add data when the buffer is full.
• A consumer does not remove data when the buffer is empty.
• Only one process accesses the buffer at a time (mutual exclusion).To solve this problem, synchronization mechanisms such as semaphores, mutex locks, or monitors are used to coordinate access to the shared buffer.
Producer-Consumer Problem
Producer-Consumer problem হলো Operating System এর একটি পরিচিত synchronization সমস্যা। এখানে এক বা একাধিক producer process data তৈরি করে একটি shared buffer এ রাখে এবং এক বা একাধিক consumer process সেই data ব্যবহার করে।
Shared buffer এর একটি সীমিত আকার থাকে, তাই producer এবং consumer এর মধ্যে সঠিক সমন্বয় প্রয়োজন হয়।
মূল Synchronization সমস্যা
এখানে প্রধান সমস্যা হলো race condition। সিস্টেমকে নিশ্চিত করতে হয় যে:
• Buffer পূর্ণ থাকলে producer নতুন data যোগ করতে পারবে না।
• Buffer খালি থাকলে consumer data নিতে পারবে না।
• একই সময়ে একাধিক process buffer access করতে পারবে না (mutual exclusion)।এই সমস্যা সমাধানের জন্য semaphore, mutex lock বা monitor ব্যবহার করে synchronization নিশ্চিত করা হয়।
- ☆27Operating SystemPage FaultsConsider 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
- ☆28Operating SystemMultithreadingWhat is Multithreading programming? Why is Multithreading used in programming?Combined Bank, AP, 24 | Assistant Programmer
Multithreading Programming
Multithreading programming is a technique where a single program is divided into multiple threads that can run at the same time. Each thread represents a small unit of execution, allowing the program to perform multiple tasks concurrently within the same process.
Why Multithreading is Used
Multithreading is used to improve the performance and responsiveness of applications. It allows better utilization of CPU resources, enables tasks to run in parallel on multi-core processors, and helps keep programs responsive while performing time-consuming operations such as file processing or network communication.
Multithreading Programming
Multithreading programming হলো এমন একটি technique যেখানে একটি program-এর ভিতরে একাধিক thread তৈরি করা হয়। প্রতিটি thread একটি ছোট execution unit হিসেবে কাজ করে এবং একই process-এর মধ্যে একসাথে একাধিক কাজ করতে পারে। এর ফলে program একই সময়ে বিভিন্ন task handle করতে সক্ষম হয়।
Multithreading কেন ব্যবহার করা হয়
Multithreading ব্যবহার করা হয় মূলত program-এর performance এবং responsiveness বাড়ানোর জন্য। এটি CPU-এর ভালো utilization নিশ্চিত করে, বিশেষ করে multi-core processor-এ parallel execution সম্ভব করে। এছাড়াও, time-consuming কাজ যেমন file processing বা network operation চলাকালীন program-কে responsive রাখতেও multithreading খুব কার্যকর।
- ☆29Operating SystemKernelA high traffic web application suddenly begins failing with database connection timeouts under peak load. At the same time, the underlying Linux OS kernel hosting the database reports "too many open files" error and network socket exhaustion. Explain the root cause of this failure at the linux os kernel level.RAKUB, ANSE, 26 | AME/ANE/AE
The failure is caused by resource exhaustion at the Linux kernel level, specifically involving file descriptors and network sockets under high load.
Key Root Causes:
File Descriptor Exhaustion:
In Linux, everything like files, sockets, and network connections is handled using file descriptors. The error "too many open files" indicates that the process or system has exceeded the ulimit (open file descriptor limit) configured in the kernel.Socket Exhaustion:
Each database connection uses a TCP socket, which also consumes file descriptors. Under heavy load, too many simultaneous connections can exhaust available kernel socket resources.Kernel Resource Limits (ulimit / sysctl constraints):
The Linux kernel enforces several limits such as:- Maximum open files per process (ulimit -n)
- System-wide file descriptor limit
- TCP socket backlog limits
When these limits are reached, the system can no longer accept new connections, causing failures or timeouts.
Connection Leak / Poor Connection Pooling:
If the application does not properly close database connections or lacks efficient connection pooling, open sockets accumulate over time, eventually exhausting available resources.Why Timeouts Occur:
- New TCP connections cannot be created due to resource limits
- Connection requests remain in SYN queue or wait state
- Database requests fail, leading to timeout errors
Overall, the root cause is Linux kernel-level resource exhaustion, mainly due to hitting file descriptor and socket limits under peak load, often worsened by poor connection management at the application level.
Root Cause (Linux Kernel Level)
এই সমস্যার মূল কারণ হলো Linux kernel-level resource exhaustion, বিশেষ করে file descriptor এবং network socket শেষ হয়ে যাওয়া।
মূল কারণসমূহ:
File Descriptor Exhaustion:
Linux-এ file, socket, database connection সবই file descriptor হিসেবে গণনা হয়। "too many open files" error মানে হলো process বা system তার ulimit (open file limit) ছাড়িয়ে গেছে।Socket Exhaustion:
প্রতিটি database connection একটি TCP socket ব্যবহার করে। বেশি load হলে available socket শেষ হয়ে যেতে পারে।Kernel Resource Limits:
Linux kernel কিছু limit enforce করে যেমন:- per-process open file limit (ulimit -n)
- system-wide file descriptor limit
- TCP backlog limit
এই limit গুলো পৌঁছে গেলে নতুন connection তৈরি হতে পারে না।
Connection Leak / Pooling Problem:
Application যদি connection properly close না করে বা connection pool ব্যবহার না করে, তাহলে open socket জমে যায় এবং ধীরে ধীরে resource exhaustion ঘটে।
Timeout কেন হয়:
- নতুন TCP connection তৈরি হতে পারে না
- Request queue বা SYN queue-তে requests আটকে যায়
- Database connection attempt ব্যর্থ হয়ে timeout হয়
মূল সমস্যা হলো Linux kernel-level file descriptor এবং socket resource exhaustion, যা high traffic এবং improper connection management-এর কারণে ঘটে।
- ☆30Operating SystemCachingHow many total bits are required of a Direct-Mapped cache with 16 KB of data and 4-word blocks, assuming a 32-bit address (word addressable) and 32-bit words?Combined Bank, O(IT), 24 | Officer (IT)
Step 1: Calculate the number of words
16 KB = 16 × 1024 = 16384 bytes
Since 1 word = 4 bytes,
Number of words = 16384 ÷ 4 = 4096 wordsStep 2: Calculate the number of blocks
Block size = 4 words
Number of blocks = 4096 ÷ 4 = 1024 blocks = 210 blocksStep 3: Determine the number of bits for index and block offset
- Index bits (n) = 10 bits (since 210 = 1024 blocks)
- Block offset bits (m) = 2 bits (since 4 words per block = 22)
- Byte offset bits = 2 bits (since 4 bytes per word = 22)Step 4: Calculate the tag size
Tag size = 32 - (n + m + 2)
= 32 - (10 + 2 + 2)
= 18 bitsStep 5: Calculate the total bits required
Each block stores:
- Data bits = 4 words × 32 bits = 128 bits
- Tag bits = 18 bits
- Valid bit = 1 bit
Total bits per block = 128 + 18 + 1 = 147 bitsTotal bits for the cache = Number of blocks × Bits per block
= 1024 × 147
= 150528 bitsFinal Answer:
150,528 bits are required for the Direct-Mapped cache.Source: Computer Science Stack Exchange
- ☆31Operating SystemBoot ProcessArrange the following in correct chronological order of computer boot process: OS Kernel Load, BIOS/UEFI POST, MBR/GPT Lookup, User Login, Driver initialization.Combined Bank, O(IT-22), 26 | Officer (IT)
Correct Chronological Order of a Computer Boot Process
The correct sequence of events during a computer’s boot process is:
- BIOS/UEFI POST: The system firmware performs Power-On Self Test to check hardware components.
- MBR/GPT Lookup: The firmware locates the bootloader information from the disk.
- OS Kernel Load: The operating system kernel is loaded into memory.
- Driver Initialization: Essential hardware drivers are initialized to make devices usable.
- User Login: The system displays the login screen for user authentication.
Final Order:
BIOS/UEFI POST → MBR/GPT Lookup → OS Kernel Load → Driver Initialization → User LoginComputer Boot Process-এর সঠিক Chronological Order
Computer boot হওয়ার সময় ধাপগুলো নিচের ক্রমে সম্পন্ন হয়:
- BIOS/UEFI POST: System firmware Power-On Self Test চালিয়ে hardware পরীক্ষা করে।
- MBR/GPT Lookup: Disk থেকে bootloader তথ্য খুঁজে বের করা হয়।
- OS Kernel Load: Operating System-এর kernel memory-তে load করা হয়।
- Driver Initialization: প্রয়োজনীয় hardware driver initialize করা হয়।
- User Login: User authentication-এর জন্য login screen দেখানো হয়।
চূড়ান্ত ক্রম:
BIOS/UEFI POST → MBR/GPT Lookup → OS Kernel Load → Driver Initialization → User Login




















Answer the following Question using the Bankers algorithm,
Explanation: