Final Exam Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

SSTF - Shortest Seek Time First

SSTF orders the queue of I/O requests by track, and picks the request on the nearest track to complete first.

Race Condition

results when several threads try to access and modify the same data concurrently --Multiple threads executing the critical section can result in this

Process vs. Thread

A process is an executing instance of an application. A thread is a path of execution within a process. The essential difference between a thread and a process is the work that each one is used to accomplish. Threads are used for small tasks, whereas processes are used for more 'heavyweight' tasks - basically the execution of applications. Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not. This allows threads to read from and write to the same data structures and variables, and also facilitates communication between threads.

Lock - Hardware Solution

Controlling Interrupts: One of the earliest solutions used to provide mutual exclusion was to disable interrupts for critical sections. This solution was invented for single-processor systems. While it is simple, the problem with this solution is inefficient because it is executed slowly by the CPU and it does not work on multiprocessors

Critical Selection

Critical section is a segment of code, in which multiple threads may be changing shared variables (or more generally, a shared resource)

Structure of VSFS

Divide the disk into blocks of some size. Assume just 64 blocks, each of size 4 KB. The blocks are addressed from 0 to 63. data region (D): user data inode table (I): meta data •data blocks used for a file; the size of the file; its owner and access rights, access and modify times; and etc. free list: bitmap •for data region (d) •for inode table (i) •superblock (S): information about this file system •number of inodes and data blocks •where the inode table begins and etc.

Extent-Based Allocation

Extent-based: A chunk of contiguous space is allocated initially.If it is not enough when the file is updated, another chunk of contiguous space (extent) is added. The location of a file's blocks is then recorded as a (first block location, block count) pair. Pros and Cons: Pros: •Minimizes head movements •Simplicity of both sequential and direct access •Particularly applicable to applications where entire files are scanned Cons for limited available extents: •External fragmentation can still be a problem •Not able to grow file when run out of extents

File-Allocation Table Allocation (FAT)

FAT: a file system developed for hard drives that originally used 12 or 16 bits for each cluster entry into the file allocation table. It is used to store file information and extend the life of a hard drive. Pros and Cons: Advantage: •Fast access Disadvantage: •lacking scalability •The entire table must be in memory all the time to make it work: ----•200-GB disk with 1-KB block size -> ----•200M entries each of which needs 3B -> ----•600MB memory

Deadlock Detection

If a RAG does not have a cycle, then no process is deadlocked. If a RAG has a cycle, then a deadlock may exist.

Lock - Yielding and Sleeping Methods

If the yielding method is used, the CPU is given up to another thread when spin is about to run and the OS toggles between the running and ready state. If the sleeping method is used, the current thread is put in to a queue to "sleep" when a thread calls lock. The "sleeping" thread is in a blocked, or waiting, state and it will not compete for the CPU while it's "sleeping". A thread in the queue will awaken when unlock is called. The sleeping method is more efficient because it does not require competition for the CPU.

Deadlock in RAG (model)

If there is a cycle in the RAG and each resource in the cycle provides only one instance then the processes/threads will be in deadlock

What is meta journalling? How does it reduce writes?

In (regular) journaling, D2 (data block to disk) is written to the journal and the update. But in metadata journaling, D2 is written only to the final location. The five major steps of meta-data journaling are data write, journal write, journal commit, checkpoint, and free. During data write, the data block to disk (D2) is written to its final location. During journal write, the inode (Iv2), transaction begin block (TxBegin, which means that there is about to be some kind of edit/update made to the file system and includes a transaction identifier (TID)), and bitmap (B2) are written to the log. During journal commit, the transaction commit block (TxEnd) is written to the log which marks this end of the update to the file system and the TID is also included. During checkpoint, the update is actually made to the file system. During free, the transaction is marked as free (or completed) in the log/journal.

Deadlock prevention vs. Deadlock Avoidance

In deadlock prevention a law is passed against one of the four necessary deadlock conditions and the problem with this approach is that it leads to low device utilization. In deadlock avoidance, global knowledge of resource usage is needed and all requests are scheduled carefully. There might be a delay on some of the requests due to this scheduling method.

Hard disk vs. Solid state disk

In its simplest form, an SSD is flash storage and has no moving parts whatsoever. As a result, they're smaller and take up less space in a PC case, in some cases even mounting directly to the motherboard. SSD storage is much faster than its HDD equivalent. HDD storage is made up of magnetic tape and has mechanical parts inside. They're larger than SSDs and much slower to read and write.

Index-Based Allocation

Index-based: Keep all pointers to blocks in one location; Multi-level index. Pros and Cons: Pros: •can be cached in memory •supports direct access •no external fragmentation Cons: •internal fragmentation on inode Problems: •what is a good size for inode? •fragmentation vs. file length

Inode; Multi-Level Inode

Inodes store the information about the file; i.e. file size, dates of modification, ownership, protection bits, location of disk blocks ------------------- Multi-level index in an inode •Direct pointers ----Directly point to blocks of the file's data •Indirect pointer ----It points to a block that contains multiple direct pointers. •Double indirect pointer ----It points to a block that contains multiple indirect pointers. •Triple indirect pointer ----It points to a block that contains multiple double indirect pointers.

C-SCAN - Circular Scan

Instead of sweeping in both directions across the disk, the algorithm only sweeps from outer-to-inner, and then resets at the outer track to begin again.•Doing so is a bit more fair to inner and outer tracks. Unfortunately, this does not represent the best scheduling technology because it ignores rotation

Linked-Based Allocation

Link-based: Scatter logical blocks throughout the disk. Link each block to next one by forward pointer. May need a backward pointer for backspacing Pros and Cons: Pros: •Flexible to use any block. Cons: •Poor direct access •Not reliable Improvement: •Maintain all pointers as a separate linked list, preferably in main memory. •Example: File-Allocation Tables (FAT) in MS-DOS, OS/2.

Polling vs. interrupt vs. DMA

Polling: CPU constantly checks device status whether it needs CPU's attention. Works Best: Where I/O devices return quickly when there is constant ready data waiting for the input Interrupt: The OS can issue a request, put the calling process to sleep, and context switch to another process. Interrupts thus allow for overlap of computation and I/O, which is key for improved utilization. Works Best: When I/O device take a long time to process DMA: Allows an input/output (I/O) device to send or receive data directly to or from the main memory, bypassing the CPU to speed up memory operations. Works Best: Large file transfers because you have specialized hardware to transfer rather than using the CPU

Holding/Waiting in RAG

Process/Thread --> Resource means that specific process/thread is waiting on that specific resource Process/Thread <-- Resource means that specific process/thread is holding that specific resource

Reading/Writing Performance and reliability among different-level RAIDs (0)

RAID •A technique to use multiple disks in concert to build a faster, bigger, and more reliable disk system.

Reading/Writing Performance and reliability among different-level RAIDs (1)

RAID •A technique to use multiple disks in concert to build a faster, bigger, and more reliable disk system.

Reading/Writing Performance and reliability among different-level RAIDs (4)

RAID •A technique to use multiple disks in concert to build a faster, bigger, and more reliable disk system.

Reading/Writing Performance and reliability among different-level RAIDs (5)

RAID •A technique to use multiple disks in concert to build a faster, bigger, and more reliable disk system.

Sequential access vs. random access

Sequential access is faster than random access •Accessing blocks in a contiguous chunk (i.e., a sequential read or write) is the fastest access mode, and usually much faster than any more random access pattern.

SCAN - Elevator

Simply moves back and forth across the disk servicing requests in order across the tracks. We call a single pass across the disk (from outer to inner tracks, or inner to outer) a sweep. Unfortunately, SCAN and its cousins do not represent the best scheduling technology. They ignore rotation.

PCB vs TCB

Some notable fields that the PCB could contain are the process id, process group id, the parent process and child processes, the heap pointer, program counter, scheduling state (running, ready, blocked), permissions (what system resources the process is allowed to access), content of the general purpose registers, and open files. TCB has a few of the same fields as the PCB (register values, stack pointer, program counter, scheduling state), in addition to a few specific values like the thread id and a pointer to the process that contains that thread. Note that there is not protection between threads.

Explain how the atomic operation TestAndSet is used to implement lock.

The atomic operation 'TestAndSet' is used to implement lock by allowing the old value to be tested while concurrently setting the memory location to a new value. The TestAndSet operation can be combined with the while loop that is in the lock function: while(TestAndSet(&lock->flag,1)==1) The new while loop will return the old flag and set the new flag as 1 at the same time. If lock is initially 1, the TestAndSet operation will replace the flag with 1 and return 1, which triggers lock. If the lock is initially 0, the TestAndSet operation will replace the flag with 1 and return 0, which would leave things unlocked.

How does journaling handle the crash issue?

The basic idea in applying journaling to address the crash issue in a file system is writing a note that describes what you are about to do before writing over the structures in place. The four major steps of journaling are journal write, journal commit, checkpoint, and free. During journal write, the inode (Iv2), transaction begin block (TxBegin, which means that there is about to be some kind of edit/update made to the file system and includes a transaction identifier (TID)), bitmap (B2), and data block to disk (D2) are written to the log. During journal commit, the transaction commit block (TxEnd) is written to the log which marks this end of the update to the file system and the TID is also included. During checkpoint, the update is actually made to the file system. During free, the transaction is marked as free (or completed) in the log/journal.

As we discussed in the class, if two threads execute the same instruction counter++, where counter is a shared variable, then a race condition happens. Explain what happens exactly

The counter++ instruction is run as an interleaved execution. The counter++ has three different parts that are on the CPU. When the interleaved execution occurs, the first two instructions for the counter++ instruction on the first thread are run. In those two instructions, the initial counter variable is copied to register1 and then is incremented by one. The context is switched to the second thread where the initial counter is copied to register2. Register2 is then incremented by one and the new value is copied back to the counter variable. Once this is finished, the context switches back the first thread where the new value of the counter variable is copied from register1. If the counter value is initially 97, each thread increment the initial counter value separately and 98 would be the new value of the counter variable.

Necessary Conditions for Deadlock

The four necessary conditions are mutual exclusion, hold and wait, no preemption, and circular wait. To prevent mutual exclusion resources can be made shareable. Requesting resources simultaneously and atomically can help prevent hold and wait. No preemption can be prevented by creating a more flexible set of interfaces. Circular lock can be prevented by imposing a total ordering on lock acquisition.

How does ffs handle long-travelling issue?

The problem with vsfs is poor performance. The fast file system (FFS) was created by a group at Berkeley to combat the problem in vsfs by creating the system to be "disk aware" which improves its performance. --Files within the same directory have their blocks allocated by placing all the files in the same directory into the group that their directory is in. --Files, in general, have their data blocks allocated in the same group as its inode. Large files have a slightly different approach to keep the entire file from filling the entire first block (maybe others). Large files have to have their blocks distributed more evenly but this creates an issue with sequential access, so the chuck size into each group has to be carefully chosen to avoid this.

I/O Canonical Devices

The three registers in canonical I/O devices are status, command, and data. The status register reads the current status of the device. The command register tells the device to perform a specific task. The data register either passes data to another device or gets data from another device. Internal structureIt is implementation specific and is responsible for implementing the abstraction (interface) the device presents to the system. •Firmware (i.e., software within a hardware device)

Log-structured FTL

Upon a write to logical page N, the device appends the write to the next free spot in the currently-being-written-to page. To allow for subsequent reads of page N, the device keeps a mapping table in its memory, and persistent, in some form, on the device •This table stores the physical address of each logical page in the system.

Writing From a File

creat("/foo/bar", ...); •Locate the directory and then create a file "bar" under the directory. ---Update inode bitmap; ---Update directory "foo" data block; ---Create "bar" inode; ---Update "foo" inode; write(fd, buffer, 4096) •Each write to a file logically generates three I/Os: ---one to read the data bitmap, which is then updated to mark the newly-allocated block as used; ---one to write the bitmap (to reflect its new state to disk); ---one to the actual block itself.

Reading From a File

open("/foo/bar", ...) Find the inode for the file "bar": •Start with root: the root inode number must be "well known": ----In most UNIX file systems, the root inode number is ----Recursively traverse the pathname. ----Finally read its destination inode into memory: ------The FS can then do a final permissions check, allocate a file descriptor for this process in the per-process open-file table, and return it to the user. read(fd, buffer, 4096) ----Read block by block of the file based on the located inode address. ----It may also update the inode with a new last-accessed time. ----The read will further update the in-memory open file table for this file descriptor: ------Updating the file offset such that the next read will read the second block of the file, and so forth.

I/O Canonical Protocol (Input)

①While (STATUS == BUSY) {;} (wait until device is not busy - polling) ②Write command to COMMAND register (lets the device know that it should begin working on the command) ③Read data from DATA register (transfer a disk block to memory) ④While (STATUS == BUSY) {;} (wait until device is done with your request - polling)

I/O Canonical Protocol (Output)

①While (STATUS == BUSY) {;} (wait until device is not busy - polling) ②Write data to DATA register (e.g., multiple writes need to take place to transfer a disk block to the device) ③Write command to COMMAND register (lets the device know that both the data is present and that it should begin working on the command) ④While (STATUS == BUSY) {;} (wait until device is done with your request - polling)


Conjuntos de estudio relacionados

Ch.59 Assessment and Management of Patients with Male Reproductive Disorders

View Set

The Federal Deposit Insurance Corporation (FDIC)

View Set

Section Two: Producer Responsibilities

View Set

Microbiology - Exam 4 - Chapters 21, 22, & 23

View Set

The Parathyroid Glands, Function and Dysfunction + Glands/Tumours Pathology

View Set

Analysis: Fundamental Analysis Review Questions

View Set