Modul 6 - Filsystem Flashcards
Benefits of interrupts over polling? (I/0)
- Interrupts allow for overlap of computation and I/O, which improves utilization.
- Instead of polling the device repeatedly the os can issue a request, put the process to sleep and do a context switch.
- When the device is finished with the I/O a interrupt is raised by the hardware and handled by the interrupt handler. Then wakes the process that issued the I/O.
When can interrupts be bad?
- If the I/O is performed quickly, interrupts can slow the process because of context switch and interrupt handling.
- In networks, when a huge stream of incoming packets each generate an interrupt, it is possible for the OS to livelock, that is, find itself only processing interrupts and never allowing a user-level process to run and actually service the requests.
- Solution: Wait a little bit before delivering an interrupt to the CPU.
How to interact with a device?
- A register to read the status of the device.
- A register to instruct the device to read or
write. - A register that holds the data.
- I/O-bus could be separate from memory bus (or the same).
- The driver will use either special I/O instructions or regular load/store instructions.
Access time for a HDD? (Seek, rotation, read)
- seek time: time to move arm to the right cylinder
- rotation time: time to rotate the disk
- read time: read one or more sectors
What is a file system?
A file system is the user space implementation of persistent storage.
- A file is persistent i.e. it survives the termination of a process
- A file can be access by several processes i.e. a shared resource
- A file can be located given a path name
What is a file?
- A sequence of bytes
Attributes, associated meta-data:
- Size and type
- Owner and permissions
- Author
- Created, last written
- Icons, fonts, presentation….
What role does the directory have in a file system?
- It maps from name to identifier.
- Contains a list of (user-readable name, low-level name) pairs.
- Each entry in a directory is either a file or other directories.
- Directories also has an inode number (low-level name)
What role does the file module have in a file system?
Locates file
What role does access control have in a file system?
Interacts with authentication system
What role does file operations have in a file system?
Read and write operations
What role does block operations have in a file system?
Which blocks on which devices
What role does device operations have in a file system?
Operations on physical drive
What is an inode number?
It’s a low level name for a file, the user is not aware of the name.
How is a file created and what happens?
- By passing the O_CREAT flag to the system call open().
- When a file is created an inode structure is created that will track all relevant information about the file (size, blocks on disk etc.)
- Then link a human-readable name to that file and putting that link into a directory.
Ex:
int fd = open(“foo”, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR);
The routine open() takes a number of different flags. In this example, the second parameter creates the file (O CREAT) if it does not exist, ensures that the file can only be written to (O WRONLY), and, if the file already exists, truncates it to a size of zero bytes thus removing any existing content (O TRUNC). The third parameter specifies permissions, in this case making the file readable and writable by the owner.
What is a file descriptor?
- A file descriptor is just an integer, private per process, and is used in UNIX systems to access files.
- Once a file is opened, the file descriptor is used to read or write the file.
- The system call open() returns a file descriptor.