Week 11 Flashcards
What is persistent storage?
Holds data regardless of whether the system is powered on/off.
Persistent storage can take several forms, commonly is based on disks.
All components of the OS and applications are kept there and loaded in main memory (RAM) when executed.
Persistent storage tends to be order of magnitude cheaper and slower than RAM so it is not used directly for program execution.
What are the requirements for OS storage management?
Performance
Support for multi-processing
Security/access control
How does the OS keep track of how many inodes and datablocks are in the file system.
We can use superblocks.
Note that they depend on the disk size.
I need to use a block (typically the first so it is easy to find) to store them!
How does persistent storage look like from the point of view of the OS?
It typically looks like an array of blocks where data can be written or read.
How is the file system organized?
It looks like a tree which organizes units of storage (files) into a hierarchial set of location (directories).
How can we keep track of free blocks?
Possible solutions:
Free block list
Bitmap: array of bits, one per block (if bit = 0 then the block is free. If bit = 1 it is occupied.)
How does the OS keep track of how many inodes and datablocks are in the filesystem?
We will use superblocks.
The size will depend on the disk size.
Typically we put the block first so its easy to find.
What is an inode?
In UNIX systems, inode tends to be a generic name for structures that hold file information.
It stands for index mode.
Inodes are typically arranged as part of a data structure on disk
What is the inode number?
Specifies a specific node within this structure.
This is called the i-number.
What is a sector?
A disk is internally partitioned into sectors, and a whole sector must be retrieved at a time.
Note sector size is determined by the disk hardware.
What is a block?
A block is a unit of allocation, the minimum of space the OS can allocate to a file.
Typically, block size = sector size * 2^n with n determined by the OS.
How does the OS retrieve content of the disk?
Compute which sector within the block the content is.
Retrieve the sector.
Retrieve the content from within the sector.
What is an indirect pointer.
An indirect pointer points to a disk block storing direct pointer.
A double indirect pointer points to a block containing indirect pointers.
In UNIX/LINUX there are two main interfaces to access files from programs
Libc I/O functions: fopen, fclose, fread, fwrite…
POSIX system calls: open, close, read, write…
What do the following do?
O_CREAT
O_WRONLY
O_TRUNC
O_CREAT: create the file if it does not exist
O_WRONLY: onlu open the file for writing
O_TRUNC: truncate the file to 0 bytes if it exists
Returns a file descriptor representing the file.