???

???

(CHECK SLIDESHOW)

Representation of File Directory

???

Directed Acyclic Structure

Implementation of File Directory

Besides name, data, and metadata, the filesystem must track:

File Control Block

Where to store this is an important design issue.

File Control Block: Data structure that encapsulates are relevant attributes of a process.

TODO There are three approaches

  1. Fixed-Size Array of ???
  2. Variable-Length Array of ???
  3. Variable-Length Array of ???

Internal Structure

Operations on Files

Open a File

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 a File

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:

  1. If the current content is modified, write the change.
  2. Update file lenght in FCB
  3. Free OFT entry
  4. Return status of the close operation to caller

Allocation

Contiguous Allocation

Definition — Sector: The smallest physical unit of memory (?).

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 Allocation

Linked Block Allocation Scheme: Rather than looking for contiguous blocks, we just go for whatever blocks are available.

Pros:

Cons:

Clustered Allocation

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)

File Allocation Table

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).

Example: Using FAT

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.

Indexed Allocation

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?

Free Space Management

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?

Example: Allocating and Deallocating Bits

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

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.

With Polling

Generic interface to device controller consists of:

Good for: Fast operations (e.g., mouse)

Cons:

With Interrupts

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)

With Direct-Memory Access

There’s a DMA controller that passes the buffer contents to main memory, offloading the work from the CPU.

Data Buffering and Caching

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.

Buffer Swapping

Technique that allows operations of a producer and consumer to overlap by using two buffers.

Circular Buffer

Like buffer swapping, but for if they are different speeds.


Error Correction

TODO

Hamming Code

Bad Block

Bad block (bad sector) is a storage block that’s no longer reliable due to physical damage.

Methods:

  1. Sector Remapping: For the bad block, jump to a spare sector.
  2. Sector Slipping: Push everything forward past the bad sector

Stable Storage

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?

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

No Redundancy | |
Full Redundancy | Every disk has the same data |
Segregated Parity | One disk caries parity bits w.r.t. to all other disks |
Distributed Parity | Like above, except the parity bits are distributed across disks |