Skip to content

Terminal Interrupt Handler

Description

The Read operation for terminal input, puts the process executing the operation to sleep while the input is being read. Once input data is read, the terminal device sends a hardware interrupt, which is handled by the terminal handler. The terminal handler is responsible for waking up processes that are blocked for input console.

The data structures modified are Terminal Status Table and Process Table.

Algorithm


Switch to the Kernel Stack.     /* See kernel stack management during system calls */
Save the value of SP to the USER SP field in the Process Table entry of the process.
Set the value of SP to the beginning of User Area Page.

Backup the register context of the current process using the BACKUP instruction.

Set the status field in Terminal Status Table to 0 to indicate that the terminal is free.

Using the PID field of the Terminal Status Table, locate the Process Table entry of the process that read the data.

Copy the word read from the standard input to the Input Buffer field in the Process Table entry.

Release lock on the terminal by calling release_terminal() function in the Resource Manager Module.

Restore the register context of the process using RESTORE instruction.

Restore SP to the value stored in USER_SP field of the process table entry of the process.

ireturn;

Question

When interrupts or system calls are invloked, the mode changes from user to kernel. Registers are backed up using the BACKUP instruction in the case of interrupts and not in the case of system calls. Why?

Back to top