(CHECK SLIDESHOW)
Besides name, data, and metadata, the filesystem must track:
Where to store this is an important design issue.
- If you store attributes directly, you could slow down the search.
File Control Block: Data structure that encapsulates are relevant attributes of a process.
TODO There are three approaches
Open File Table: Data structure that tracks all files currently in use.
Open File Operation: Prepares a file for efficient access by TODO
Whenever you update a file, you never update just a block. Everything wr.t. the file in memory has to be erased and re-added.
Close file reverses the effects of the open operation by saving the state of the file in the FCB and freeing the OFT entry.
Steps:
Definition — Sector: The smallest physical unit of memory (?).
- A sector is hardware-level and can vary depending on manufacterer.
- TODO Like, smallest addressable?
A contiguous disk block is allocated via sector.
TODO details of operation, from 8.5.1
Access is really fast because we have random-access.
Linked Block Allocation Scheme: Rather than looking for contiguous blocks, we just go for whatever blocks are available.
Pros:
Cons:
Combination approach, we will allocate whatever contiguous clusters we can, but the entire file doesn’t need to be contiguous.
This still has the issue of being really weak to hardware failure of a single block.
Aside — Both of these methods below also mitigate loss of a block (no longer breaks the chain)
TODO Definition, and 8.5.7
The FCBs must be loaded somehow, but having them all in memory might be too costly/impossible.
TODO It’s like how in scaled partial pivoting we could introduce a pivot array to make swapping faster (spacetime tradeoff).
Suppose the file blocks 0,1,2,3 reside in the disk blocks 14,17,3,9; respectievly.
The FAT will link them together like
| i | value |
|---|---|
| … | … |
| 3 | 9 |
| … | … |
| 9 | 2 |
| … | … |
| 14 | 17 |
| … | … |
| 17 | 3 |
Arrays are really fast, so we don’t need pointer shenanigans.
inodes, a very smart way of allocation.
Rather than a FAT, we have index tables bridge the FCB and disk blocks.
TODO I did not understand the explanation. Something something 1-level 2-level and it allows massive allocation?
Bitmap: Data structure that represents the allocation status of a disk.
TODO Okay but like, why we are maintaining a bitmap? How how do you use this?
Deallocation: Doing logical AND with 11011111 will make the third bit 0
Allocation: Doing logical OR with 11011111 will make the third bit 1
Programmed I/O: Style of I/O programming where the CPU does everything.
TODO “Programmed I/O with Polling” table:
| Register | Use |
|---|---|
| TODO |
(TODO NOTE TO SELF: All methods use the same registers, so I’ve moved the table here)
TODO Explanations of all three methods are quite unclear.
Generic interface to device controller consists of:
Good for: Fast operations (e.g., mouse)
Cons:
Rather than keeping the CPU busy checking the busy flag over-and-over, the process will block itself and the I/O device will send an interrupt on its own.
Good for: Slow operations (e.g., printer)
There’s a DMA controller that passes the buffer contents to main memory, offloading the work from the CPU.
Buffer: Register or area of main memory that holds data generated by a producer and is removed later by a consumer.
Example — a printer will have a buffer to sync its speed (TODO what?)
Raw Input Mode: TODO
Cooked Input Mode: TODO
Example: Suppose you type: “t e s t
x In Raw Input mode, the application would get this sequence of characters and have to parse it.
In Cooked Input mode, the application would simply get “text”
TODO I don’t understand how or why this happens.
Technique that allows operations of a producer and consumer to overlap by using two buffers.
Like buffer swapping, but for if they are different speeds.
TODO
Bad block (bad sector) is a storage block that’s no longer reliable due to physical damage.
Methods:
Stable Storage: Approach to data management that uses redundance along with a strict protoocl for reading, writing, and error recovery.
| TODO | |
|---|---|
| Stable Read | |
| Stable Write | |
| System Crash | |
| Media Recovery |
everything is atomic
we keep shadow copies of things
so like RAID?
A set of disks is
Since probability of media failure increases rapidly with the number of disks, redundancy is used to decrease the probability of data loss.
TODO