CONTEXT SWITCHING WITH REGARDS TO USER MODE AND KERNEL MODE

CONTEXT SWITCHING WITH REGARDS TO USER MODE AND KERNEL MODE

The processor switches between two mode depending on what type of code is running on the processor Application run in user mode and core operating component runs in kernel mode.

The processor must have a hardware support for user/kernel mode. System call interface (SCI) are the only way to transmit from user space to kernel space. Context switching happen between mode in an operating system namely: User mode and Kernel mode

Context switching is a moving between the user mode and the kernel mode. The occurs when a user process makes a request to the underlying system API before the switch is done, an interrupt is generated. An interrupt handler then save the state of the CPU, switches to the kernel mode where the CPU can execute the instruction, and then restore the state of the C.P.U and returns to user mode.

Furthermore, A context switching occurs when the kernel transfers control of the C.P.U from an executing process to another that is ready to run.

DIFFERENCE BETWEEN USER MODE AND KERNEL MODE:

When a program is booted up on an operating system let’s say window, then it launches the program in user mode. And when a user mode program request to run, a process and virtual address space (address space for that process) is created for it by windows. User mode program are less privileged than user-mode application and are not allowed to access the system resources directly. For instance, if an application under user-mode wants to access system resources, it will have to first go through the operating system kernel by using syscalls.

Kernel Mode: The kernel is the core program on which all the other operating system components rely, it is used to access the hardware components and schedule which process should run on a computer system and when, and it also manages the application software and hardware interaction. Hence it is the most privileged program, unlike other programs it can directly interact with the hardware. When programs running under user mode need hardware access for example webcam, then first it has to go through the kernel by suing a syscall, and to carry out these request the C.P.U switches from user mode to kernel mode at the time of execution. After finally completing the execution of the process the C.P.U again switches back to the user mode.

FUNCTIONS OF A KERNEL IN OPERATING SYSTEM

  1. Scheduling Process: The kernel provide a part of the time to each process, when a process has finished executions the kernel starts another process, determines the state of the running, waiting or ended.
  2. Resources Allocation: The kernel controls memory, peripheral devices and C.P.U processes. It also cats as link between resources and processes.
  3. Device Management: The kernel manages the devices connect with the system, such as I/O device, storage devices etc. and also the exchange of data through these devices.
  4. Interrupt Handling and System Calls: When a process runs, there may arise a task of high priority that needs to be executed first. The kernel switches the control from the currently running process to the new one as per their priorities.
  5. Memory Management: Once the kernel creates and execute a process, it lives in memory having occupied space in it. When the process ends, the kernel removes the process from the memory. Kernel assigns the memory to process and release it as well.
  6. Process Management: The kernel performs the creation, execution, and ending of processes that run in the system. When a system has to execute any task, the kernel creates and manages the processes.

IN CONCLUSION:

  1. Kernel is central module of an operating system. It is that part of an OS that loads first and remains in the main memory.
  2. Kernel example are Zircon, Linux, windows NT, etc.
  3. Kernel are of five types, namely monolithic, microkernel, nanokernel, hybrid kernel and exokernel.
  4. Function of a kernel include scheduling process, resource allocation, device management, interrupt handling, memory management, and process management.

Leave a Reply

Your email address will not be published. Required fields are marked *