Storage 1: OS input/output, memory hierarchy

Overview

Full lecture notes on storageTextbook readings

Examples of efficiency in computer systems

WeensyOS pipe improvements

System calls for reading and writing

File descriptor system calls

Creating file descriptors

Devices and files

Durable storage

Creating a file one byte at a time

Write a file one byte at a time using system calls

    size_t n = 0;
    while (n < size) {
        ssize_t r = write(fd, buf, 1);
        if (r != 1) {
            perror("write");
            exit(1);
        }
        ++n;
    }

Write a file one byte at a time using the stdio library

    size_t n = 0;
    while (n < size) {
        int ch = fputc(buf[0], f);
        if (ch == EOF) {
            perror("write");
            exit(1);
        }
        ++n;
    }

Question 1

Investigating standard I/O

What is standard I/O doing?

Cache