Thursday, July 2, 2020

Process Management in Linux : Time Slicing and Context Switching

Hi,

In this post I am going to discuss about the Context Switching and Time Slicing in Linux.

As we all know that Linux operating system classifies the memory into two space namely....

1. User Space
2. Kernel Space

The user space is where the user processes run and kernel space is where the kernel processes run, the purpose of kernel in Linux operating system is that it acts as a resource manager.

In Linux, the kernel treats everything as resource including the hardware, this abstraction would make the kernel to switch the resources between two modes namely

1. User Mode
2. Kernel Mode

One of the restrictions is Linux is that no User Process can access the hard ware resource directly without the knowledge of kernel, in order to gain access to the hardware resources, the kernel must set the hardware resource to user mode i.e for the User Process to gain access over the hardware resource and start using them.

For our discussion, let us take Central Processing Unit(CPU).

In Linux the central processing unit is a resource from the kernel's point of view so that it can switch the modes of CPU between user to kernel and vice versa.

Whenever the CPU is at the User Mode, it means the User Process is utilizing the CPU.

What the hell is Time Slicing?

Time Slicing is a process in which the kernel decides how long a user process could make use of the CPU.

What is Context Switching?

Context Switching is a process of giving up the control over CPU by a User Process to an other User Process to gain control over the CPU for a specified time slice.

Context Switching is the time duration where the Linux kernel comes in and does the house keeping(Memory, State of the Process etc...) work of the User Process that is about to give away the control of the CPU and prepares the memory for the next User Process that is about to gain the control of the CPU.

The following Image would let you understand in a comprehensive way...


Well that is it, hope you had great time reading.

Thanks.


No comments:

Post a Comment

Addressing Modes of 8080 / 8085 MicroProcessor

Hi,   In this post I am going to talk about different addressing modes of 8080/8085...without much talking let us get into the topic.   Ther...