Oral Questions 2018 Flashcards
Structure of directory entry
The directory entry provides the information needed to find the disk blocks. Depending on the system, this information may be: the disk address of the entire file (with contiguous allocation), the number of the first block (both linked-list schemes), or the number of the i-node. (UNIX V7, ISO 9660)
System call “exec”
Command exec in Linux is used to execute a command from the bash itself. This command does not create a new process it just replaces the bash with the command to be executed. If the exec command is successful, it does not return to the calling process.
DMA structure
“Direct Memory Address (DMA) contains several registers that can be written and read by the CPU. These include a memory address register, a byte count register, and one or more control registers.
The control registers specify the I/O port to use, the direction of the transfer (reading from the I/O device or writing to the I/O device), the transfer unit (byte at a time or word at a time), and the number of bytes to transfer in one burst.”
Advantages and disadvantages of small and big pages
“Small page size advantages:
– It reduces internal fragmentation.
– It will help to allocate small programs consisting of several phases. The smaller the page size is, the less memory will be wasted.
Small page size disadvantages:
– Having many pages means a large page table.
– Transferring a small page takes almost as much time as transferring a large page.
– Small pages use up much valuable space in the TLB.”
Conditions for deadlocks
“Four conditions that must hold for there to be a (resource) deadlock:
– Mutual exclusion condition: Each resource is either currently assigned to exactly one process or is available.
– Hold and wait condition: Processes currently holding resources that were granted earlier can request new resources.
– No preemption condition: Resources previously granted cannot be forcibly taken away from a process. They must be explicitly released by the process holding them.
– Circular wait condition: There must be a circular list of two or more processes, each of which is waiting for a resource held by the next member of the chain.”
Paging and segmentation
“Paging: To get a large linear address space without having to buy more physical memory.
Segmentation: To allow programs and data to be broken up into logically independent address spaces and to aid sharing and protection.”
Scheduling
The part of the OS that makes the choice is called the scheduler, and the algorithm it uses is called the scheduling algorithm.
Difference between virtual and physical memory
“– Physical memory is actual RAM, while virtual memory is a memory management technique that creates an illusion to users of a larger physical memory.
– Physical memory is faster than virtual memory.
– Physical memory uses swapping technique, while vitual memory uses paging.
– Physical memory is limited to the size of the RAM chip, while virtual memory is limited by the size of the hard disk. Physical memory can directly access the CPU, and virtual memory cannot.”
TLB and Inverted page tables
“TLB (Transition Lookaside Buffer) or associative memory is small hardware device for mapping virtual addresses to physical addresses without going through the page table. When a virtual address is presented to the MMU for translation, the hardware first checks to see if its virtual page number is present in the TLB by comparing it to all the entries in parallel. If a valid match is found and the access does not violate the protection bits, the page frame is taken directly from the TLB (a protection fault is generated otherwise).
Inverted page tables: There is one entry per page frame in real memory, rather than one entry per page of virtual address space, so the size is proportional to physical memory, not the virtual address space. The entry contains a pair (process ID, virtual page address) and refers to a page frame.
Pitfall of inverted page tables: When process n references virtual page p, it is no longer possible to find the physical page by using p as an index into the page table. Instead, we must search the entire inverted page table for an entry (n, p). This search must be done on every memory reference, not just on page faults.”
Can the size of virtual memory be less than size of physical memory?
Yes, it can (Suppose 8-GB RAM and 32-bit processor).
Segmentation in Intel x86-64
In x86-64 CPUs, segmentation is considered obsolete and is no longer supported, except in legacy mode.
Difference between hard links and soft links
“Hard links: A directory may contain several filenames that all map to the same i-node number and thus to the same file in the file system. Unix call these names pointers or links to the file. Hard links are new names for the same i-node. Link count in the i-node keeps track of how many directories contain a name number mapping for that i-node. Hard links cannot be made to a directory. This restriction means that every subdirectory has one and only one parent directory. A hard link and data it links to, must always exist in the same file system.
Soft links: A soft link or symbolic link contains a path to another file or directory and may point to any file or directory. Soft links can cross file systems.”
“Structure of i-nodes
Where they are stored?
Protection bits”
“I-node (index-node) is associated with each file, which lists the attributes and disk addresses of the file’s blocks. Each i-node stores the attributes and disk block locations of the object’s data. File-system object attributes may include metadata (times of last change, access, modification), as well as owner and permission data.
Advantages of i-nodes:
– Only i-node for a file which is open must be in memory.
– Requires an array in memory whose size is proportional to the maximum number of files that may be open at once.
I-nodes are stored on disk.
Protection bits tell what kinds of access are permitted. In the simplest form, this field contains 1 bit, with 0 for read/write and 1 for read only. A more sophisticated arrangement is having 3 bits, one bit each for enabling reading, writing, and executing the page.”
WSClock algorithm (Page replacing)
An algorithm which is based on the clock algorithm but also uses the working set information. Is widely used in practice since it is simple and provides good performance. The data structure is a circular, initially empty, list of page frames, as in the clock algorithm. As the pages are added, they go into the list to form a ring. Each entry contains the Time of last use field from the basic working set algorithm, as well as the R and M bits.
Processes and threads: differences, advantages and disadvantages. Context switch
“Context switch is a procedure that a CPU follows to change from one process to another while ensuring that the tasks do not conflict.
A context switch can be performed entirely in hardware (physical media). Older CPUs, such as those in the x86 series, do it that way. However, most modern CPUs perform context switches by means of software (programming). A modern CPU can perform hundreds of context switches per second. Therefore, the user gets the impression that the computer is performing multiple tasks in a parallel fashion, when the CPU actually alternates or rotates between or among the tasks at a high rate of speed.”
Mount table
Mounted table is a table of mounted disks.
How Shortest Remaining Time First algorithm estimate how long process will execute?
We should know it in advance.
What is FAT?
File Allocation Table
“What is i-node? What it contains?
Can we have hard link in different partition?
Can we hard link directory?
Is inode created on soft link?”
“I-node (index-node) is associated with each file, which lists the attributes and disk addresses of the file’s blocks. Each i-node stores the attributes and disk block locations of the object’s data. File-system object attributes may include metadata (times of last change, access, modification), as well as owner and permission data.
A directory may contain several filenames that all map to the same i-node number and thus to the same file in the file system. Unix call these names pointers or links to the file.
Hard link and data it links to, must always exist in the same file system.
Hard links cannot be made to a directory. This restriction means that every subdirectory has one and only one parent directory.
Soft link or symbolic link contains a path to another file or directory and may point to any file or directory.”
Compare LRU and NFU algorithms
“LRU (Least Recently Used) algorithm: When a page fault occurs, throw out the page that has been unused for the longest time (not cheap to implement).
NFU (Not Frequently Used): It is software simulation of LRU. NFU requires a software counter associated with each page, initially zero. At each clock interrupt the OS scans all the pages in memory and updates the counter by adding R bit to it. When a page fault occurs, the page with the lowest counter is chosen for replacement.”
What is TLB?
TLB (Transition Lookaside Buffer) or associative memory is small hardware device for mapping virtual addresses to physical addresses without going through the page table.
Fork and execve
In UNIX, there is only one system call to create a new process: fork, which creates an exact clone of the calling process. After the fork, the parent and the child processes, have the same memory image, environment strings and open files. Usually, the child process then executes execve or a similar system call to change its memory image and run a new program. The child can manipulate its file descriptors after the fork but before the execve in order to accomplish redirection of standard input, standard output, and standard error.