Lecture 8
Multi-Level Feedback Queues
The multi-level feedback queue (MLFQ) is a scheduling system that we'll have to
implement in xv6 as part of PA 3 for this class. In CSCI 350 Lecture 8, Prof.
Ryutov spells out the exact pseudocode for the procedure, so I'll write it here
as a boilerplate for when it's time to code this out.
quantum
: the duration of time a task will be scheduled for
priority
: the precedence of a particular task
there are multiple queues, with each queue having a lower priority than the one
before it. The lower a queue is in priority, the higher its corresponding
quantum value will be.
Whenever a new process arrives, it is appended to the back of the queue with the
highest priority. *It will interrupt the current process when it arrives*. If
the currently running process is not a top-priority process, this newly arriving
task will preempt whatever is taking place right now, and the processor will
prioritize the task that just arrived, allowing it to run for the full quantum.
The process at the head of the queue will continue to run until the duration it
has been running for begins to exceed the quantum corresponding to the priority
level of this particular queue. At that moment, it will be removed from the CPU,
and will be appended to the tail of the next-lowest level of priority queue.
Then, the scheduler will run the process that's up to bat next.
Topic: File Systems
Traditional file system implementations were optimized for magnetic hard disk drives (HDD)
Today's file systems are optimized for solid state disks (SSDs), and are known as Copy-on-Write File Systems
You will not be tested on anything that isn't covered after today
Paging vs. Segmentation
- Both are techniques for non-contiguous memory allocation
Contiguous memory allocation
Solid State Disks (SSDs)
A solid state disk is just a device with is full of flash memory chips.
Has no moving parts, if you drop a HDD, you can break the head easily
Eliminates seek and rotational delay
Data is divided into blocks, and blocks are divided into pages
Data written in 4KB pages, but data erased in 256KB blocks
Writes must be to "clean" cells. Can only write empty pages in a block.
Erasing a block takes ~1.5ms
How does the controller maintain a pool of empty blocks?
The controller maintains a pool of empty blocks by coalescing the used pages (read, erase, write), and additionally, by reserving some percentage of total capacity.
Heavily used blocks wear out pretty quickly.
FTL
FTL maps logival block adddress to physical address
FAT
Advantages:
- Simple
- Easy to find free blocks
- Easy to append to a file
Disadvantages
- Poor locality
- Random access is pretty slow
- Fragmentation
- File blocks for a given file may be scattered
- Files in the same directory may be scattered
- MSDOS defrag tool
- Limited Metadata, no access control info
- No support for reliability, hard links
- Max file size is 4GB
Fast File System (FFS)
Advantages
- Efficient storage for lookup for random access in large files
- Locality for large files
- Locality for large metadata and data
Disadvantages
- Inefficient for tiny files, since files with barely any data still need an inode and a data block
- Inefficient encoding when file is mostly contiguous on disk
- Need to reserve some free space to prevent fragmentation
Midterm definitely has questions on FAT and FFS