Difference between Internal fragmentation and External fragmentation

Difference between Internal and External fragmentation

Internal Fragmentation External Fragmentation
When a process is allocated more memory than required, few space is left unused and this is called as INTERNAL FRAGMENTATION After execution of processes when they are swapped out of memory and other smaller processes replace them, many small non contiguous(adjacent) blocks of unused spaces are formed which can serve a new request if all of them are put together but as they are not adjacent to each other a new request can’t be served and this is known as EXTERNAL FRAGMENTATION.
It occurs when memory is divided into fixed-sized partitions. It occurs when memory is divided into variable-sized partitions based on size of process.
It can be cured by allocating memory dynamically or having partitions of different sizes. It can be cured by Compaction, Paging and Segmentation.

Here is a short video i made to help you understand better!

Internal Fragmentation

Screen Shot 2017-07-27 at 12.05.21 PM

  • It arises when we use fixed sized partitioning.
  • Some part of the memory is kept for operating system and the rest is available for user space.
  • In this case the user space is divided into blocks of 10 KB each.
  • When process 1 with size 8 KB is allocated a block of 10 KB, 2 KB space is left unused. When process 2 with size 10 KB is allocated a !0 KB block no space is left unused. When process 3 with size 9KB is allocated a 10 KB block, 1KB is left unused.
  • Here 2 processes are allocated space more than required and this unused space is so small to store a new process and is wasted. This is called as INTERNAL FRAGMENTATION.

External Fragmentation

Screen Shot 2017-07-27 at 12.05.47 PM

  • It arises when dynamic partitioning technique is used.
  • Here memory is allocated  to the processes dynamically based on their size.
  • So in the above example, the user space contains processes 1,2 & 3 Out of which process 1 & 3 complete their execution and are swapped out and two other processes, process 4 & 5 are swapped in their places.
  • Process 4 takes place of process 1 but as its size is only 8 KB, it is allocated only 8 KB and rest is left unused.
  • Process 5 takes place of process 3. It is allocated 6 KB space and 8 KB is left unused.
  • Now suppose a new process, process 6 wants to be swapped in and its size is 6 KB. Though we have total 6 KB space but we cannot service this request as these blocks are not contiguous(adjacent). This is called as EXTERNAL FRAGMENTATION.



Screen Shot 2017-07-13 at 3.43.34 PM

  • System calls provide an interface between user programs and operating system.
  • It is a programmatic way in which a computer program requests a service from the kernel of the operating system.

Here is a short video i made which will help you understand better.

Let us first understand the 2 modes in which a program executes.


  • User mode
  • Kernel mode

When a program is executing in user mode, it is not in privileged mode. So whenever it needs any hardware resource like RAM or printer, it needs to make a call to the kernel and this is known as SYSTEM CALL.

When a program is executing in kernel mode, it is executing in privileged mode. So it can access any hardware resource. So when a program needs to access any resource while it is running in user mode it makes a System Call to the kernel then a context switch occurs which takes the program from user mode to kernel mode. After the resource is accessed one more context switch occurs which takes back the program’s execution to user mode.

Now you may wonder why aren’t all programs occurring in kernel mode so we can skip the context switching. This is because if a program crashes in kernel mode entire system will be halted. So most programs are executed in user mode because if it crashes there, entire system won’t be affected.

Now let us take an example.

Screen Shot 2017-07-13 at 4.09.42 PM


If we want to write a program to copy the content of one file into another then, first of all this program will need the names of these files. User will give these names by either typing them in the console or selecting them by using GUI. So our program will need to make system calls to the kernel to enable it to access the input and output devices.

Also our program will need to display certain message if the program is successfully completed or even if it stops and is aborted. All these tasks require System calls.


A) Process Control

Processes need to be controlled as in a running process must be able to halt its execution either normally or abnormally.Also one process may need to run some other process to complete its own execution. So all these system calls come under this category.

  • end, abort
  • load, execute
  • create process, terminate process
  • get process attributes, set process attributes
  • wait for time, wait event, signal event
  • allocate and free memory

B) File Management

System calls which deal with operations related to files fall under this type.

  • create file, delete file
  • open, close
  • read, write, reposition
  • get file attributes, set file attributes

C) Device Management

A process may need several resources for its execution. So system calls used for asking permission from the kernel to use those resources are included in this type.

  • request device, release device
  • read, write, reposition
  • get device attributes, set device attributes
  • logically attach or detach devices

D) Information Maintenance

We need to keep all the information up to date so these system calls help us to do that.

  • get time or date, set time or date
  • get system data, set system data
  • get process, file, or device attributes
  • set process, file, or device attributes

E) Communication

Processes need to communicate with each other for many reasons like if they need certain resource which is held by any other process. These system calls assist in doing so.

  • create, delete communication connection
  • send, receive messages
  • transfer status information
  • attach or detach remote devices


What is RAID? Different levels of RAID(0-6,10)

RAID- Redundant Array of Inexpensive/Independent Disks

  • RAID is the technique in which we use multiple physical hard disks which all together act as a single logical hard disk.

harddriveharddriveharddrive equaltoharddrive

  • Initially, RAID was known as Redundant Array of Inexpensive Disks because larger hard disks were costly, so we used multiple smaller disks.
  • Nowadays we use RAID to increase performance and reliability so now RAID is Redundant Array of Independent Disks.
  • Based on certain criteria how these multiple hard drives are used we have different RAID levels.

Here is a short video which i made to help you understand better!

RAID Levels



  • In RAID 0 all the data is striped and equally divided among the number of available disks.
  • Striping can be bitwise/byte wise/block wise.
  • Redundancy is not present as the same data is not copied anywhere else.
  • Performance is better as more than one disk participates in read/write operation.
  • Consider this example- If one man is asked to write A-Z the amount of time taken by him will be more as compared to 2 men writing A-Z because from the 2 men one man will write A-M and another will write N-Z  at the same time so this will speed up the process.
  • Hence, more the number of disks involved in read/write operation better will be the performance.
  • As there is no redundancy i.e. no copy of data is maintained reliability is low. So if any one of the disk fails we lose the data.



  • In RAID 1 we perform mirroring.
  • We mirror i.e make copies of all the available data.
  • This is expensive as more number of disks are required to make copies.
  • It is reliable because if one disk is lost we already have another copy of it.
  • It doesn’t help in increasing the performance.



  • RAID 2 uses Error Correcting code like Hamming code to restore the damaged data.
  • More than 2 bits are used for storing ECC so minimum 3 dedicated disks are required for storing ECC with 1bit on each disk.
  • Data is split bit wise across the data storing disks(Here from disk 0 – disk 3) while ECC is stored in ECC storing disks(Here disk 4 – disk 6)
  • This is expensive as more disks are required.
  • It lowers the write operation as for every write operation ECC has to be calculated which is time consuming.



  • In RAID 2 we used minimum 3 dedicated disks to store ECC
  • In RAID 3 we use the concept of Parity instead of ECC.
  • In this case Parity is XOR values of A1,A2 and A3. If they contain even number of 1s then Parity is set to 0 and if they contain odd number of 1s then Parity is set to 1.
  • Only 1 bit is used so this requires only 1 dedicated disk.
  • RAID 3 increases the performance as all the disks participate in every read/write operation.
  • It doesn’t increase number of simultaneous accesses as all the disks participate in each read/write operation so no disk is available to service other read/write request.



  • RAID 4 is similar to RAID 3. The only difference is that in RAID 3 we split the data bit wise but in RAID 4 we split the data block wise.
  • As blocks are bigger than bits, so smaller read/write operations involve only one disk. So other disks are free to service other read/write requests so RAID 4 increases the number of simultaneous accesses.
  • As only one disk is involved performance is not increased.
  • It is mainly suitable for larger read/write operations in which many blocks of data will have to be either read or written, so more than one disk will be involved which will boost the performance.



  • In RAID 3 and RAID 4 one dedicated disk was used to store the parity information. If this disk fails we will lose our entire backup.
  • To overcome this flaw in RAID 5 we distribute the parity data evenly among all the disks.
  • Any formula can be used to distribute it evenly.(example- as we have 5 disks here parity of nth block will be stored in n(mod 5)+1 disk.)
  • Here one parity bit per block is stored in a disk chosen by the formula and the actual data is divided among the other disks.
  • This reduces the potential overuse of a single disk.
  • As only one bit of parity is stored we can overcome failures if only 1 disk fails, if more than 1 disk fails RAID 5 cannot help in recovering the damaged data.



  • RAID 6 is similar to RAID 5.
  • In  RAID 5 we used only one parity bit but in RAID 6 we use more than one parity bit.
  • This extra bit contains extra redundant information which helps to recover from multiple disk failures.


  • This is the hybrid of  RAID 0 and RAID 1
  • So it gives better performance as well as reliability.
  • RAID 0 – Striping of data
  • RAID 1- Mirroring of data

RAID 0+1


  • Here first we mirror the available data and form copies of it.
  • Then we stripe those copies.

RAID 1+0


  • Here we first stripe the data.
  • Then we mirror the striped data to form copies.

Monolithic kernel vs Microkernel

Here is a short video i made to help you understand better!

 The Difference between 

The entire O.S. is placed inside the kernel Only bare minimum code is placed inside the kernel (only basic memory management and Inter Process Communication code)
It runs as a single large process Here the kernel is broken down into processes called as servers
As all the services are placed inside the kernel, they have a single address space As services(Servers provide services) are separated they have different address spaces
It is bigger in size It is smaller in size
It is easy to implement/code It is tough to implement/code
Performance is high (As kernel can invoke any function directly as everything is placed in the kernel) Performance is low (As servers are separated, so to invoke services from other servers IPC(Inter Process Communication) is needed which requires kernel’s permission and thus increases access time and lowers the performance)
Less Secure (If one service fails, entire system crashes) More Secure (Even if one service crashes, others can function properly because of separation)