What happens When program requests hardware related service such as accessing hard disk drive
Whenever a program requests a hard disk drive or any other hardware, an interrupt signal is sent to the processor.
The processor then prepares itself to give the control of the hardware to the requesting program.
As a result, the execution of the current program using the hard disk drive is paused.
The contents of the program counter (the register which keeps track of the currently executing step of the program) is written on to a stack. This will help to start the current program again from where it had stopped.
Now, the requesting program will start execution, hence taking the control of the hard disk drive.
The program counter will be loaded with the address of the new program.
Once, the new program is completed, the stack will be popped, the stack content will be loaded to the program counter and the previous program will start again.
What happens When program requests hardware related service such as accessing hard disk drive