Operating System Tutorial

Operating System Tutorial Types of Operating System Evolution of Operating System Functions of Operating System Operating System Properties Operating System Services Components of Operating System Needs of the Operating System

Operating Systems

Linux Operating System Unix Operating System Ubuntu Operating System Chrome Operating Systems Fedora Operating System MAC Operating System MS Windows Operating System Solaris Operating System Cooperative Operating System CorelDRAW Operating System CentOS FreeBSD Operating Systems Batch Operating System MS-DOS Operating System Commercial Mobile Operating Systems

Differences

Difference Between Multi-programming and Multitasking Difference between C-LOOK and C-SCAN Difference between Rotational Latency and Disk Assess Time Trap vs Interrupt Difference between C-SCAN and SSTF Difference between SCAN and FCFS Difference between Seek Time and Disk Access Time Difference between SSTF and LOOK Difference between Process and Program in the Operating System Difference between Protection and Security in Operating System

How To

How to implement Monitors using Semaphores How to Install a Different Operating System on a PC

Questions

What is Kernel and Types of Kernel What is DOS Operating System What is Thread and Types of Thread What is Process Scheduler and Process Queue What is Context Switching What is CPU Scheduling What is Producer-Consumer Problem What is Semaphore in Operating System Monitors in Operating System What is Deadlock What is Paging and Segmentation What is Demand Paging What is Virtual Memory What is a Long term Scheduler What is Page Replacement in Operating System What is BSR Mode What is Convoy Effect What is Job Sequencing in Operating System Why is it critical for the Scheduler to distinguish between I/O-bound and CPU-bound programs Why is there a Need for an Operating System

Misc

Process Management Process State Scheduling Algorithm FCFS (First-come-First-Serve) Scheduling SJF (Shortest Job First) Scheduling Round-Robin CPU Scheduling Priority Based Scheduling HRRN (Highest Response Ratio Next) Scheduling Process Synchronization Lock Variable Mechanism TSL Mechanism Turn Variable Mechanism Interested Variable Mechanism Deadlock Avoidance Strategies for Handling Deadlock Deadlock Prevention Deadlock Detection and Recovery Resource Allocation Graph Banker’s Algorithm in Operating System Fixed Partitioning and Dynamic Partitioning Partitioning Algorithms Disk Scheduling Algorithms FCFS and SSTF Disk Scheduling Algorithm SCAN and C-SCAN Disk Scheduling Algorithm Look and C-Look Disk Scheduling Algorithm File in Operating System File Access Methods in Operating System File Allocation Method Directory Structure in Operating System N-Step-SCAN Disk Scheduling Feedback Queue in Operating System Contiguous Memory Allocation in Operating System Real-time Operating System Starvation in Operating System Thrashing in Operating System 5 Goals of Operating System Advantages of Operating System Advantages of UNIX Operating System Bit Vector in Operating System Booting Process in Operating System Can a Computer Run Without the Operating System Dining Philosophers Problem in Operating System Free Space Management in Operating System Inter Process Communication in Operating System Swapping in Operating System Memory Management in Operating System Multiprogramming Operating System Multitasking Operating Systems Multi-user Operating Systems Non-Contiguous Memory Allocation in Operating System Page Table in Operating System Process Scheduling in Operating System Segmentation in Operating System Simple Structure in Operating System Single-User Operating System Two Phase Locking Protocol Advantages and Disadvantages of Operating System Arithmetic operations in binary number system Assemblers in the operating system Bakery Algorithm in Operating System Benefits of Ubuntu Operating System CPU Scheduling Criteria in Operating System Critical Section in Operating System Device Management in Operating System Linux Scheduler in Operating System Long Term Scheduler in Operating System Mutex in Operating System Operating System Failure Peterson's Solution in Operating System Privileged and Non-Privileged Instructions in Operating System Swapping in Operating System Types of Operating System Zombie and Orphan Process in Operating System 62-bit operating system Advantages and Disadvantages of Batch Operating System Boot Block and Bad Block in Operating System Contiguous and Non - Contiguous Memory Allocation in Operating System Control and Distribution Systems in Operations Management Control Program in Operating System Convergent Technologies in Operating System Convoy Effect in Operating System Copy Operating Systems to SSD Core Components of Operating System Core of UNIX Operating System Correct Value to return to the Operating System Corrupted Operating System Cos is Smart Card Operating System Cosmos Operating Systems Examples Generation of Operating System Hardware Solution in Operating System Process Control Block in Operating System Function of Kernel in Operating System Operating System Layers History of Debian Operating Systems Branches and Architecture of Debian Operating Systems Features and Packages of Debian Operating Systems Installation of Operating System on a New PC Organizational Structure and Development in Debian Operating Systems User Interface in Operating System Types Of Memory in OS Operating System in Nokia Multilevel Paging in OS Memory Mapping Techniques in OS Memory Layout of a Process in Operating System Hardware Protection in Operating System Functions of File Management in Operating System Core of Linux Operating System Cache Replacement Policy in Operating System Cache Line and Cache Size in Operating System What is Memory Mapping? Difference Between Network Operating System And Distributed Operating System What is the difference between a Hard link and a Soft Link? Principles of Preemptive Scheduling Process Scheduling Algorithms What is NOS? What is the Interrupt I/O Process? What is Time Sharing OS What is process termination? What is Time-Sharing Operating System What is Batch File File system manipulation

Fixed Partitioning in Operating System

Fixed Partitioning in OS

Fixed Partitioning is also known as Contiguous memory allocation. Fixed Partitioning is the easiest method, which is used to load more than one process into the main memory.

In Fixed Partitioning, we divide the main memory into partitions, and the size of partitions can be different or equal. In the first partition, the operating system is present, and the remaining partitions are used to store the user processes. In a contiguous way, we allocate the memory to the processes.

In the fixed Partitioning:

  1. There is no overlapping of partitions.
  2. For the process execution, the process should be present contiguously.

Disadvantages of Fixed Partitioning

The disadvantages of Fixed Partitioning are:

  1. Internal Fragmentation: - In fixed partitioning, the partitions will be wasted and remain unused if the process size is lesser than the total size of the partition. In this way, memory gets wasted, and this is called Internal fragmentation.

We can see in the fixed partitioning diagram that for loading a process of 3 MB, we use the partition of 4 MB, and in this way, 1 MB is getting wasted. Thus, this is the drawback of fixed partitioning.

  • External Fragmentation: - We cannot use the total amount of unused space of different partitions to put the process even in the situation when we have some space available, but not in contiguous form. We can see in the fixed partitioning diagram, that we cannot use the 1 MB remaining space of each of the partition to store the process of 4 MB. Instead of that, we have a space available to load the process, but we cannot load the process. Such type of fragmentation is known as External Fragmentation.
  • Limitation on the Size of the Process: - Sometimes, when the size of the process is larger than the maximum partition size, then we cannot load that process into the memory. So, this is the main disadvantage of the fixed partition.
  • Degree of Multiprogramming is Less: - We can understand from the degree of multiprogramming that it means at the same time, the maximum number of processes we can load into the memory. In Fixed Partitioning, the size of the partition is fixed, and we cannot vary it according to the process size; therefore, in fixed partitioning, the degree of multiprogramming is less and fixed.
Fixed Partitioning

Dynamic Partitioning: - Dynamic Partitioning is another technique for memory management that is invented to remove the problems that arises in the Fixed Partitioning technique. In dynamic partitioning, we do not declare the size of the partition in the starting. Instead, we declare the size of partition at the time of its loading.

In this, the operating system, reserves the first partition. The rest of the other space is divided into different sections. The size of the partition and the size of the process remain equal. In dynamic partitioning, we can avoid the problem of internal fragmentation by varying the size of partition based on the needs of the process.

Fixed Partitioning

Advantages of Dynamic Partitioning over Fixed Partitioning

The advantages of dynamic partitioning over fixed partitioning are:

  1. No Limitation on the size of the process: - In fixed partitioning, if the size of the process is larger than the size of the partition, we cannot put or load the process into the memory. But if we talk about dynamic partitioning, the size of the process cannot be fixed, and we can change the size of partition according to the size of the process.
  2. The Degree of Multiprogramming is dynamic: -In Dynamic Partition, there is no internal fragmentation, so there is no unused space that is present in the partition. So at the same time, we can load more number of processes in the memory.
  3. No Internal Fragmentation: - In Dynamic Partitioning, the partitions are created dynamically as per the need for the process. So, in dynamic partitioning, internal fragmentation is not present, and the reason behind is that in dynamic partition, there is no space in the partition which remains unused.

Disadvantages of dynamic partitioning

The disadvantages of dynamic partitioning are:

  1. Complex Memory Allocation: - In the case of fixed Partitioning, if once we create the list of partitions, we cannot modify it again. But in the case of dynamic partition, the task of allocation and deallocation is tough because the size of the partition varies whenever the partition is allocated to the new process. The operating system has to keep track of each of the partitions.

So, due to the difficulty of allocation and deallocation in the dynamic memory allocation, and every time we have to change the size of the partition; therefore, it is tough for the operating system to handle everything.

  • External Fragmentation: - One of the main disadvantages of dynamic partitioning is external fragmentation.

Suppose we have three processes P1 (1MB), P2 (3MB), and P3 (1MB), and we want to load the processes in the various   partitions of the main memory.

Now the processes P1 and P3 are completed, and space that is assigned to the process P1 and P3 is freed. Now we have partitions of 1 MB each, which are unused and present in the main memory, but we cannot use this space to load the process of 2 MB in the memory because space is not contiguous.

The rule says that we can load the process into the memory only when it is contiguously residing in the main memory. So, if we want to avoid external fragmentation, then we have to change this rule.

Fixed Partitioning

What is Compaction

Compaction is also known as Defragmentation. In dynamic Partitioning, there is a problem of external fragmentation, and due to external fragmentation, some critical problems can happen.

If we want to remove the problem of compaction, we have to change the rule that says, in memory, we cannot store the process in different places. Compaction is also used to reduce the possibility of external fragmentation. In this, the partitions which are free are made contiguous, and all the partitions which are loaded are carried together.

With the help of compaction, we can easily store the processes in the memory that are bigger in size.

In this, free partitions are merged and then used. These merged partitions are allocated to other processes according to their need.

We can see in the below figure, there is process P5 which we cannot load into the memory because we don’t have space in a contiguous manner. But with the help of the compaction technique, we can load the process P5 in the memory because, by the compaction technique, we made the free partitions contiguous.

Fixed Partitioning

Problem with Compaction

Due to compaction, the system efficiency is decreased because we need to move all the free spaces from one place to other.

In this way, the more amount of time is wasted, and the CPU remains ideal all the time. Instead of that, with the help of compaction, we can avoid external fragmentation, but this will make the system inefficient.