CS3210 Design Operating Systems

Taesoo Kim





Q1 Review

Minions of Taesoo Kim

Administrivia

Administrivia

Rustling #1

let v0 = String::from("Hello World!");
let v1 = vec![
    String::from("Hello"),
    String::from(" "),
    String::from("World!"),
];
let v2 = vec!["Hello", " ", "World!"];
let v3 = ["Hello", " ", "World!"];
let v4 = &v0;

Rustling #2

fn main(){
    let s1 = String::from("hello world");
    let s2 = "hello world";

    println!("{}", _______________ );
}

Rustling #3

let x: i64 = ...;

if (x < 0) {
    if (x < -x) {
        println!("1");
    } else {
        println!("2");
    }
} else {
    println!("3");
}

Rustling #4

trait Summary {
    fn summary(&self) -> String;
}

// A.
fn new_summary(option: u32) -> Summary { ... }
// B.
fn new_summary<T: Summary>(option: u32) -> T { ... }
// C.
fn new_summary(option: u32) -> &impl Summary { ... }
// D.
fn new_summary(option: u32) -> &dyn Summary { ... }
// E.
fn new_summary(option: u32) -> Box<dyn Summary> { ... }

Rustling #5

struct TextField<'a>(&'a str);
struct InputForm<'a>(Vec<TextField<'a>>);

fn insert_field __________________________ {
    in_form.0.push(TextField(txt));
}

fn main(){
    let mut in_form = InputForm(Vec::new());
    insert_field(&mut in_form, "First Name");
    insert_field(&mut in_form, "Second Name");
    ...
}

Rustling #6

struct Stack();
trait ID { fn who_am_i(&self); }
impl ID for Stack {
    fn who_am_i(&self) { print!("A"); }
}
impl ID for &Stack {
    fn who_am_i(&self){ print!("B"); }
}
fn main(){
    let x = Stack();
    x.who_am_i();
    let y = &x;
    y.who_am_i();
    let z = &y;
    z.who_am_i();
}

Rustling #7

use std::mem;

fn always_returns_true(x: u8) -> bool {
    x < 150 || x > 120
}
fn main() {
    let x: u8 = unsafe { mem::uninitialized() };
    println!("{}", always_returns_true(x));
}

Size of TAT #11

Size of Cluster #12

Size of Cluster #13

  1. Cluster Size
    • 1-byte can address 256 clusters
    • Size of TAT : 1 Byte * 256 entreis = 256 Bytes
    • Size of Cluster : (64KB - 256 Bytes) / 256 entries = 255 Bytes
  2. Size of Data Region
    • (64KB - 256 Bytes) / 64KB = 99.6%
  3. Biggest File Size
    • 64KB - 256 Bytes = 65280 Bytes

Size of Cluster #14

Inlined TAF #15

  1. Size of a file
    • (255 Bytes * 3 Clusters) + 0xE0 = 989 Bytes
  2. Why TAF is faster?
  3. Avoid moving data when append data
  4. Disadvantages?