COS3721 ASSIGNMENT 1 SOLUTIONS 2021
QUESTION 1
1.1What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps
be generated intentionally by a user program? If so, for what purpose?
Answer:
An interrupt is a hardware‐generated change‐of
flow within the system. An interrupt handler is summoned to deal with the cause of the interrupt
control is then returned to the interrupted context and instruction. A trap is a software‐
generated interrupt. An interrupt can be used to signal the completion of an I/O to obviate the nee
d for device polling. A trap can best
use to call operating system routines or to catch arithmetic errors.
1.2 Discuss, with examples, how the problem of maintaining coherence of cached data
manifests itself in the following processing environments:
Let us look at the following example:
Suppose an integer A which is to be incremented by 1 is located in file B, and file B resides in m
agnetic disk. The increment operation proceeds by first issuing an I/O operation to copy the dis
k block on which A resides to main memory. This operation is followed by copying A to the ca
che and to an internal register. Thus, the copy of A
appears in several places; on the magnetic disk, in main memory, in the cache and in an internal
register (Fig below).
Once the increment takes place in the internal register, the value of A differs in the various stora
ge systems. The
value of A becomes the same only after the new value of A is written from the internal register b
ack to the magnetic disk.
QUESTION 1
1.1What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps
be generated intentionally by a user program? If so, for what purpose?
Answer:
An interrupt is a hardware‐generated change‐of
flow within the system. An interrupt handler is summoned to deal with the cause of the interrupt
control is then returned to the interrupted context and instruction. A trap is a software‐
generated interrupt. An interrupt can be used to signal the completion of an I/O to obviate the nee
d for device polling. A trap can best
use to call operating system routines or to catch arithmetic errors.
1.2 Discuss, with examples, how the problem of maintaining coherence of cached data
manifests itself in the following processing environments:
Let us look at the following example:
Suppose an integer A which is to be incremented by 1 is located in file B, and file B resides in m
agnetic disk. The increment operation proceeds by first issuing an I/O operation to copy the dis
k block on which A resides to main memory. This operation is followed by copying A to the ca
che and to an internal register. Thus, the copy of A
appears in several places; on the magnetic disk, in main memory, in the cache and in an internal
register (Fig below).
Once the increment takes place in the internal register, the value of A differs in the various stora
ge systems. The
value of A becomes the same only after the new value of A is written from the internal register b
ack to the magnetic disk.