心得分享

Card image cap

李同學 報告/作業 分享經驗 104.10.13 10/8 OS作業

104.10.13 10/8 OS作業
名稱 10/8 OS作業
日期 104.10.13
課程名稱 作業系統
指導教師 劉艾華

1.Give two reasons why caches are useful.
What problems do they solve?
What problems do they cause?
If a cache can be made as large as the device for which it is caching
(for instance, a cache as large as a disk), why not make it that large and eliminate the device?

Caches are useful due to numerous reasons. For instance, caches are helpful when two or more components exchange data, and the components perform transfers at differing speeds.
They solve the transfer problem via offering a buffer of transitional speed among the components. For case, if the speedy apparatus finds the data it needs in the cache, then there is no need to wait for the slower device.
If a component has a data value change, and the datum is also in the cache, the cache must also be updated. This is especially a problem on multiprocessor systems where more than one process may be accessing a datum.
A component may be eliminated by an equal-sized cache, but only if:the cache and the component have equivalent state-saving capacity (that is, if the component retains its data when electricity is removed, the cache must retain data as well), and the cache is affordable, because faster storage tends to be more expensive.

2.What Is the purpose of interrupts? What are the differences between a trap and an interrupt?
Can traps be generated intentionally by a user program?
If so, for what purpose?
Interrupt is that causes a computer processor to temporarily stop executing its current program and execute another program instead, finally returning control to the original program. So it prevent that more important task goes back because of less important task.
The main difference between a trap and an interrupt is where they are generated. An interrupt is a hardware-generated. And it can be used to signal the completion of an I/O to obviate the need for device polling. Whereas a trap is software-generated interrupt and it can be used to call operating system routines or to catch arithmetic errors.
A trap can be generated intentionally by a user program.
It can be used to call operating system routines or to catch arithmetic errors.

3.Please tell the functional differences between CPU and device controller.
Is there any similarity between them?

A device controller is a part of a computer system that makes sense of the signals going to, and coming from the CPU.A general-purpose computer system consists of CPUs and multiple device controllers that are connected through a common bus. Each device controller is in charge of a specific type of device. The device controller is responsible for moving the data between the peripheral devices that it controls and its local buffer storage. Typically, operating systems have a device driver for each device controller. This device driver understands the device controller and presents a uniform interface for the device to the rest of the operating system.

4.Please discuss, in your own words, the cycle of the handling of an interrupt.
Hardware:
Device controller or other system hardware issues an interrupt.
Processor finishes execution of current instruction.
Processor signals acknowledgment of interrupt.
Once the current instruction execution is completed, the processor initiates the interrupt handling by saving the current register contents on the stack.
Processor loads new PC value based on interrupt.
Software:
Save remainder of process state information.
Process interrupt.
Restore process state information.
Restore old PSW and PC.

更新日期:2015/10/15 上午 10:06:31