13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Device drivers 161address of the data on the deviceaddress of the data in main storeamount of data to transferwhether the data are to be read or writtenwhat kernel module is waiting for the completion of this operation3.1 Two levels of device driverDevice drivers must serve two masters: the rest of the kernel and the device itself. Thekernel indicates its desires by calling the routines just mentioned, asking for data to beread or written. When these transfers are complete, the device driver is expected toinform the appropriate kernel module. (We will discuss how the individual kernelmodules can signal each other in Chapters 8 and 9. For now, imagine that there are littleprocesses, which we will call tasks, in the kernel, and that one is waiting for the completionof this transput operation. It is the job of the device driver to unblock that task onceits request has been satisfied.) The device itself is given commands by the device driver.When these commands have been accomplished, the device causes an interrupt. Thisinterrupt is set to transfer control to the appropriate device driver.One useful organization for device drivers to help them deal with these very differentsorts of requests is to divide them into two pieces. Each driver has an ‘‘upper’’and a ‘‘lower’’ part. The two parts communicate by sharing data structures. This organizationis shown in Figure 5.8.The upper part accepts requests from the rest of the kernel. For example, the upperpart of the disk driver might accept a request from the storage manager to write out aprocesseskernel taskopenclosereadwritekernelawakenupper driverinsertreorderwork queuelower driverremoveinterruptdevicescontrolFigure 5.8 Two-level structure of a device driver

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!