Week 31
CST334 Week 7
This week was our seventh week in CST-334, also known as Operating Systems
Operating Systems: Three Easy Pieces
Chapter 36: I/O Devices
Chapter 36 discusses the basics of I/O devices.
Key Takeaways:
- Interrupts are used to tell the CPU when a I/O request is complete.
- A Direct Memory Access (DMA) engine is a specialized device for handling I/O requests.
- Explicit I/O instructions and memory-mapped I/O are two ways to interact with I/O devices.
- Device Drivers is a piece of software that knows how a device works, and abstracts that device to the system.
- A basic protocol for an I/O device might be:
- Wait for drive to be ready.
- Write parameters to command registers.
- Start the I/O.
- Data transfer (for writes).
- Handle interrupts.
- Error handling.
Chapter 37: Hard Disk Drives
Chapter 37 discusses hard disk drives.
Key Takeaways:
- Data in HDDs is partitioned in blocks.
- A platter is a circular, hard surface within a HDD that stores data. Each platter has two sides, and HDDs may have more than one platter.
- "Rows" on a platter are called tracks.
- "Columns" on a platter are called sectors.
- The head is a mechanism that reads/writes data to and from the platter.
- Seeking is when the head moves to a new position.
- Shortest Seek Time First (SSTF) prioritizes the requests for the closest block. It can starve requests for far-away blocks.
- Elevator (SCAN or C-SCAN) scheduling moves up and down the platter repeatedly, avoiding starvation.
The following formulas are used for calculating average request time:
- T-total = (# reads) * T-access + T-transfer
- T-access = T-seek + T-rotation
- T-rotation = 1-minute/X-rotations * 60-seconds/1-minute * 1000-ms/1-second * 1-revolution/2
- T-transfer = (number of reads * size of reads)-KB/1 * 1-MB/1024-KB * 1-second/(transfer rate)-MB * 1000-ms/1-second
Chapter 39: Files and Directories
Chapter 39 discusses files and directories.
Key Takeaways:
- Files have a low-level name, called an inode number.
- Directories are special files that contain (user-readable name, inode numeber) pairs.
- The open() function is used to open and/or create new files. It returns a file descriptor.
- A file descriptor is a pointer to a file. They are tracked by the OS on a per process basis.
- The functions read() and write() are used to read and write to files.
- The function lseek() updates the offset used when accessing a file.
- The function fsync() is used to immediately schedule data to be written to the disk.
- The function unlink() is used to remove a reference to a file. The file is deleted when its last reference is removed.
- The function mkdir() creates a new directory.
- The function rmdir() removes a directory. A directory must be empty for it to be removed.
- The function link() creates a new hard link to a file.
- Soft links are files that link to another file.
Chapter 40: File System Implementation
Chapter 40 discusses how file systems are implemented.
Key Takeaways:
- Some of a file structure is reserved for metadata.
- An inode table stores inode data.
- Data and inode bitmaps store whether an inode or piece of data is free.
- The superblock stores extra information about the file system.
- Direct pointers inside of inodes point to blocks contained within a file.
- Indirect pointers point to a block that contains additional direct or indirect pointers.
The following formulas can be used to calculate inode location:
- Address = Start of inode blocks + inode number * inode size
- Block Number = Address // block size
- Location in Block = Address % block size
- Which inode in block = Location in Block // inode size
Comments
Post a Comment