Dq Week 1

Submitted by: Submitted by

Views: 87

Words: 265

Pages: 2

Category: Other Topics

Date Submitted: 03/24/2014 09:05 AM

Report This Essay

What are the differences between an interrupt and a trap? Provide an example of each. What is their importance?

Interrupt is usually are reserved for hardware interrupts, which are program control interruptions caused by external hardware. Hardware interrupts comes from different sources such as keyboards, mouse, I/O ports, disk drives and other external hardware. An event like pressing a button or even an internal hardware timer timing out can cause this type of interrupt. The CPU will stop whatever it is doing and will provide a type of service that the devices needs and will get back to the program. AN example of when hardware interrupt happens is when I/O operation is completed such as reading data onto the computer from a tape drive. Traps are software-invoked interrupts and is an exception in a user process. Trap is caused by a division by zero or an invalid memory access. Traps can also be used to catch arithmetic errors or call system routines. It also a way to invoke a kernel routine because those run with a higher priority than user code. Trap is also sometimes called Exception. The trap will make the CPU to stop what it was doing depending on trap condition. The context then will be saved then the CPU will jump to an appropriate trap routine. The term traps refers to an interrupt intended to initiate a context switch to a monitor program debugger. An example of a trap would be deferred trap which is a trap is raised later after an exception instructions has had any effects.