------------------------------------------------------ Lecture 17 - March 12, 2003 ------------------------------------------------------ AGENDA: 0 Admin 1 P5 questions? 2 Ch 3.5: block devices in MINIX 3 Ch 3.6: RAM disks in MINIX ------------------------------------------------------ 0 - ADMIN ------------------------------------------------------ Startout Q: What types of operations does a block device support? Due today: * RI #5: Covers Ch 3.4-7 (pp. 179-222) Local friendly Dungeon programming contest this Saturday (March 15). 1-3:30pm or so. Details TBA, but pencil it in on your calendars. ------------------------------------------------------ 1 - P5 QUESTIONS? ------------------------------------------------------ Questions? ------------------------------------------------------ 2 - CH 3.5: BLOCK DEVICES IN MINIX ------------------------------------------------------ Questions? OVERVIEW Initialization Then go into infinite loop fielding requests * get message * do work and send reply * sharing common code while calling separate service routines in C. See fig 3-17 p. 188. - example of threads sharing same code while doing different work. This takes it further than you would normally think of with threads. The 6 device driver operations 1) Open - verify device is accessible 2) Close - guarantees that buffered data written out to final destination. 3) Read - only returns to caller when data transferred to user buffer. 4) Write - may buffer data and return immediately. 5) Ioctl - used to change device parameters. E.g., changing speed for serial line. 6) Scattered_IO - can request the reading/writing of multiple blocks at once. This has the potential to be more efficient. Give the driver a sorted list of blocks to read/write and can specify whether optional or mandatory per block. Run through driver.h (pp. 635-636) + driver.c pp. 636-641. COMMON BLOCK DEVICE SOFTWARE The 64K DMA boundary problem * address is specified by a 16-bit counter plus 4- or 8-bit latch. When counter overflows and wraps around, no carry to latch, so suddenly reference an address 64K lower. * discuss how to solve - allocate a buffer twice required space - makes for some really strange errors if don't handle correctly. DRIVER LIBRARY Partitioning devices 1) Cheaper to partition a larger device that have separate devices. 2) O/S may have file system size limits. 3) Many have multiple file system types. 4) Sometimes convenient to have separate logical device as in when copy root file system to ram disk. Put all the machine-specific partition table info here in one place. ------------------------------------------------------ 3 - CH 3.6: RAM DISKS IN MINIX ------------------------------------------------------ What is a RAM disk? Pros and cons? - could probably run MINIX entirely from RAM disk - Discuss passing comment about systems that support mounted file systems vs. those that don't. Minor devices 0: /dev/ram - true RAM disk, same size as root file system by default 1: /dev/mem - used to read and write physical memory addresses, starding at absolute 0 (kelvin). Can be useful for system devices, debugging, etc. 2: /dev/kmem - like /dev/mem, but address 0 is the first byte of the kernel memory. Used for debugging and special programs that need to peek at kernel data structures (e.g. ps). 3: /dev/null - high compression level data device. Unfortunately, this uses a destructive compression algorithm and reduces all input to size of 0 bytes. When read from, produces instant end of file. Look through code pp. 645-649. COS 421 - Lecture Notes #17 SPRING 2003 COS421-lect-2003-03-12.doc Page 1 Printed 12.03.03