Open In App

What is Reentrant Kernel?

Last Updated : 04 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Reentrant Kernel: In kernel mode, a reentrant kernel allows processes (or, more precisely, their corresponding kernel threads) to give up the CPU. They have no effect on other processes entering kernel mode. Multiple processor systems may be scheduled together in the case of single-processor systems.

Example:

A disc read is an example of this. When a user program requests a disc read, the scheduler will delegate the CPU to another process (kernel thread) until the disc controller issues an interrupt indicating that the data is accessible and our thread can be resumed. This process can still access I/O, such as user input, which requires kernel functions. The system remains responsive, and the amount of CPU time wasted as a result of IO delays is reduced. The original function (whatever requested data) would be blocked in a non-reentrant kernel until the disc read was completed.

If a computer program or routine can be safely called again before its previous invocation has been completed, it is said to be reentrant (i.e it can be safely executed concurrently). A computer program or routine that is reentrant:

  • There cannot be any non-constant data that is static (or global).
  • The address must not be returned to static (or global) non-constant data.
  • It must only work with the data provided by the caller.
  • Locks should not be used to protect singleton resources, a variable that is only referenced once
  • It must not change its own code (unless executing in its own unique thread storage).
  • Non-reentrant computer programs or routines must not be called.

Non-reentrant functions can still be executed by reentrant kernels if locks are used to ensure that only one process can run the non-reentrant function. Even though the current process is operating in kernel mode, hardware interrupts can suspend it (allowing things like Ctrl+c to cease execution).

Kernel Control Path: A set of instructions that the kernel executes in order to handle a system call. Normally, instructions are executed in order, but some activities force the CPU to interleave control routes. In user mode, the following system call is made: The scheduler chooses a new process to run and switches it on. On behalf of two separate processes, two control pathways are executed.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads