Ad Code

Timer in CPU Protection - Dual Mode Operation in Hardware Protection

Timer in CPU Protection

 In a multiple processing system we want to make sure the multiple processes can be run so CPU can be switched between different processes running at a time.

CPU Scheduling:

If multiple processes wants to process their work at a time then CPU first assigned to process1 for specific amount of time and similarly to process 2 and so on to all the other processes. The technique of given CPU to the multiple processes is called CPU scheduling.

As multiple processes are using CPU, we need to make sure that a single process is not using the CPU for an infinite time period so we need a timer which is loaded with a predetermined time and fix interval clock which periodically interrupt the CPU and when this clock interrupt, timer value is decremented by 1 and when timer value is 0 a special type of interrupt is generate which is called timer interrupt and Interrupt service routine (ISR) is execute which take the CPU from previous process and give it to the next process.

Dual Mode Operation in Hardware Protection


There are two CPU modes by which CPU can execute instructions. One is privileged or restricted mode also called kernel mode and other is non-privileged or unrestricted mode also called user mode. When the CPU is in Kernel mode, it has complete control on everything such as access of memory addresses, reading from a file etc so if any user program which is in the user mode wants to execute a system call i.e new process creation, I/O operations then it is done through system call in privileged mode. A system call is the request by the user program to the operating system’s kernel

For example at system boot time, the hardware starts in monitor mode. The operating system is then loaded, and starts user processes in user mode. Whenever a trap or interrupt occurs, the hardware switches from user mode to monitor mode. Thus, whenever the operating system gains control of the computer, it is in monitor mode. The system always switches to user mode (by setting the mode bit to 1) before passing control to user program. 

The dual mode of operation provides us with the means for protecting the operating system from users can harm each other or can disturb the working of privileged mode. We accomplish this protection by designating some of the machine instructions that may cause harm as privileged instructions. The hardware allows privileged instructions to be executed only in monitor mode. If an attempt is made to execute a privileged instruction in user mode, the hardware does not execute the instruction, but rather treats the instruction as illegal and traps it to the operating system.
Reactions

Post a Comment

0 Comments