Modul 6 - Filsystem Flashcards

1
Q

Benefits of interrupts over polling? (I/0)

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When can interrupts be bad?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to interact with a device?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Access time for a HDD? (Seek, rotation, read)

A
  • seek time: time to move arm to the right cylinder
  • rotation time: time to rotate the disk
  • read time: read one or more sectors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a file system?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a file?

A
  • A sequence of bytes

Attributes, associated meta-data:

  • Size and type
  • Owner and permissions
  • Author
  • Created, last written
  • Icons, fonts, presentation….
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What role does the directory have in a file system?

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What role does the file module have in a file system?

A

Locates file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What role does access control have in a file system?

A

Interacts with authentication system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What role does file operations have in a file system?

A

Read and write operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What role does block operations have in a file system?

A

Which blocks on which devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What role does device operations have in a file system?

A

Operations on physical drive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an inode number?

A

It’s a low level name for a file, the user is not aware of the name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How is a file created and what happens?

A
  • 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a file descriptor?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does lseek() system call do?

A
  • Used to read or write to a specific offset within a file. (specific location)
off_t lseek(int fildes, off_t offset, int whence);
First argument is the file descriptor, second is the offset and the third determines how the seek is performed.
17
Q

What is a open file table?

A
  • Open file table contains entries of the file descriptors that each process has (processes maintains these in an array).

. Table is global, one entry per open operation

  • Also contains the current offset and information such as whether the file is readable or writable.
18
Q

When does processes share file tables entries?

A
  • When a parent process creates a child process with fork().
19
Q

What happens if different processes reads the same file at the same time?

A

If the open file table isn’t shared, then each logical reading or writing of a file is independent.

20
Q

What happens when a file table is shared?

A
  • When a file table entry is shared, its reference count is incremented; only when both processes close the file (or exit) will the entry be removed.
  • Sharing open file table entries across parent and child is occasionally useful. For example, if you create a number of processes that are cooperatively working on a task, they can write to the same output file without any extra coordination.
21
Q

What does dup() system call do?

A
  • The dup() call allows a process to create a new file descriptor that refers to the same underlying open file as an existing descriptor.
  • The dup() call (and, in particular, dup2()) are useful when writing a UNIX shell and performing operations like output redirection;
22
Q

What does fsync() system call do?

A
  • When a process calls fsync() for a particular file descriptor, the file system responds by forcing all dirty
    (i. e., not yet written) data to disk, for the file referred to by the specified file descriptor. The fsync() routine returns once all of these writes are complete.
23
Q

What is a hard link?

A
  • A hard link is a way to create a link between a new file name to an old one. Basically you create another way to refer to the same file.
24
Q

What does the system call link() do?

A
  • Creates a hard link between two file names.
  • link() takes two arguments, an old pathname and a new one.
  • Command-line program ln is used to do this.
  • The way link works is that it simply creates another name in the directory you are creating the link to, and refers it to the same inode number (i.e., low-level name) of the original file. The file is not copied in any way
25
Q

What does unlink() system call do?

A
  • Removes a file from the file system.

- By removing the hard links of the file.

26
Q

What are symbolic links (soft links)?

A
  • A way to link to a directory (which hard links can’t).
  • Way to link to files in other disk partitions. (Hard links can’t because inode numbers are only unique within a particular files system).
  • Symbolic links are actually quite different from hard links. The first difference is that a symbolic link is actually a file itself, of a different type.
  • Can leave dangling references if the original file is removed.
27
Q

What does mount do?

A
  • Mount unifies all file systems into one tree.
28
Q

Inode tables?

A
  • Inode table: one table per file system, one entry per file object
  • Stores inodes which holds information (owner, access rights, file size etc) of the files in a file system.
29
Q

What does a file table entry hold?

A

The file table entry holds:
- Reference to inode

  • Reference counter, when it reaches 0 the file is closed and the entry is removed
  • The current position in the file
  • Read and write access rights, determined when opened
30
Q

What is a bitmap?

A

It’s a simple structure which tracks data blocks are free or allocated. Each bit is used to indicate whether the corresponding object/block is free (0) or in-use (1).

  • One for the data region (data bitmap) and one for the inode table (inode bitmap)
31
Q

What is the data region?

A
  • It’s the region of the disk that is used for user data.

- Most of the space in a file system is user data.

32
Q

How is the space in a disk divided for a file system?

A

It’s divided into blocks, commonly-used size of 4kb.

33
Q

What are the components of a file system?

A
  • Data blocks (D)
  • Inodes (I)
  • Inode bitmap (i)
  • Data bitmap (d)
  • Superblock (S)
34
Q

What information does the superblock contain?

A
  • A superblock contains information about the file system, including for example how many inodes and data blocks are in the file system, where the inode table begins etc.
35
Q

What is the inode datastructure?

A

The inode is a structure that holds the metadata for a given file, such as its length, permissions, and the location of its constituent blocks. It is short for index node, as the inode number is used to index into an array of on-disk inodes in order to find the inode of that number.

36
Q

How are inodes designed?

A
  • To support bigger files, file system designers have had to introduce different structures within inodes.
  • One common idea is to have a special pointer known as an indirect pointer. Instead of pointing to a block that contains user data, it points to a block that contains more pointers, each of which point to user data.
  • To support even larger files, add another pointer to the inode: the double indirect pointer. This pointer refers to a block that contains pointers to indirect blocks, each of which contain pointers to data blocks.
  • You can have triple indirect pointer or more (supports even larger files).
  • Overall, this imbalanced tree is referred to as themulti-level index approach to pointing to file blocks.
37
Q

Where are directories stored?

A

Often, file systems treat directories as a special type of file. Thus, a directory has an inode, somewhere in the inode table (with the type field of the inode marked as “directory” instead of “regular file”). The directory has data blocks pointed to by the inode (and perhaps, indirect blocks); these data blocks live in the data block region of our simple file system.

38
Q

How do we reduce the number of I/O to the (slow) disk when reading, writing or opening files?

A
  • Most systems use system memory (DRAM) to cache important blocks.
  • Modern systems, employ a dynamic partitioning approach. Specifically, many modern operating systems integrate virtual memory pages and file system pages into a unified page cache. In this way,memory can be allocated more flexibly across virtual memory and file system, depending on which needs more memory at a given time.
  • Write buffering, delaying writes so that the file system can batch some updates into smaller set of I/O’s.
  • Most modern file systems bufferwrites in memory
    for anywhere between five and thirty seconds, representing yet another trade-off: if the system crashes before the updates have been propagated
    to disk, the updates are lost; however, by keeping writes in memory longer, performance can be improved by batching, scheduling, and even avoiding writes.