1
votes

My thoughts:

Suppose two applications are running in parallel in Linux x86 (multi-tasking), and they both share keyboard peripheral. if I press a button on keyboard, interrupt occurs and control has to switch to corresponding interrupt routine. The starting address of interrupt routine for an interrupt source is obtained from Interrupt vector table which is already defined from 0x0000. But two applications may need different routines for the same keyboard interrupt. So the routine to be executed should depend on from which task it was actually interrupted.

So does this mean that two separate interrupt vector tables have to be kept for both processes and they are loaded by kernel while processes switch on time slices???

1

1 Answers

1
votes

A process running in a user address space can not service interrupts and thus does not have a vector table. The interrupt vector table will reside in the kernels address space.

In the case of a keyboard, the kernel's vector table(s) will handle the interrupt and pickup the key press. The kernel then will send the character from the key press to the user application via a system call. In linux, the system call will most likely be abstracted as a file being read by the user processes.

Multiple user processes (applications in this example) can read from the same file, so the behavior depends on the specifics of the file/file like device. There is a good chance it will end up being an unpredictable race between processes to read the data first. In practice, its often a bad idea to have multiple processes concurrently accessing the same file.