OS Midterm PDF Questions
What is a slab list of free slots/chunks?
(object pool) a cache for a certain type or size of data object has a number of pre-allocated "slabs" of memory; within each slab there are memory chunks of fixed size suitable for the objects - mostly kernel use - mostly very small - slab allocation is used for kernel memory allocation
What are character devices?
- A character (char) device is one that can be accessed as a stream of bytes (like a file) - A character device is any device that can have streams of characters read from or written to it - devices that do not have physically addressable storage media where I/O is normally performed in a byte stream - a character device driver communicates by sending and receiving single characters
What is swapping?
- A process must be in memory to be executed. However, a process can be swapped temporarily out of memory to a backing store and then brought back into memory for continued execution - Processes are swapped in and out of main memory to the disk => In a time shared system, swapping is done to ensure a reasonable response time
What is an operating system?
- A program that manages the computer hardware - Acts as an intermediary between the computer user and the computer hardware - a control system for smart gadgets, but it is really a layer between hardware and software
What is shared memory?
- A region of memory that is shared by cooperating processes is established. Processes can exchange info by reading and writing data to the shared region - Pros: Allows max speed and convenience of communication
What are slabs?
- A slab is made up of one or more physically contiguous pages - A cache consists of one or more slabs. There is a single cache for each unique kernel data structure (i.e., a separate cache for the data structure representing process descriptors, a separate cache for file objects, a separate cache for semaphores, etc.) - Each cache is populated with objects that are instantiations of the kernel data structure the cache represents.
What does the malloc() function do?
- AKA memory allocation method - used to dynamically allocate a single large block of memory with a specified size - returns a pointer of type void which can be cast into a pointer of any form - does NOT initialize memory at execution time so that it has initializes each block with the default garbage value initially
What are block devices?
- Block devices are characterized by random access to data organized in fixed-size blocks - A block device is a computer data storage device that supports reading and (optionally) writing data in fixed-size blocks - a block device driver communicates by sending entire blocks of data.
What is message passing?
- Communication takes place by means of messages exchanged between the cooperating processes - Pros: useful for exchanging smaller amounts of data, easier to implement
How do holes in memory allocation work?
- One of the simplest methods for allocating memory is to divide memory into several fixed-sized partitions. Each partition may contain exactly one process. - In the scheme, the operating system keeps a table indicating which parts of memory are available and which are occupied. Initially, all memory is available for user processes and is considered one large block of available memory, a hole. Memory contains a set of holes of various sizes. - At any given time, then, we have a list of available block sizes and an input queue. The operating system can order the input queue according to a scheduling algorithm. Memory is allocated to processes until finally, the memory requirements of the next process cannot be satisfied-that is, no available block of memory (or hole) is large enough to hold that process. The operating system can then wait until a large enough block is available, or it can skip down the input queue to see whether the smaller memory requirements of some other process can be met. - the memory blocks available comprise a set of holes of various sizes scattered throughout memory. When a process arrives and needs memory, the system searches the set for a hole that is large enough for this process. If the hole is too large, it is split into two parts. One part is allocated to the arriving process; the other is returned to the set of holes. When a process terminates, it releases its block of memory, which is then placed back in the set of holes. If the new hole is adjacent to other holes, these adjacent holes are merged to form one larger hole.
What does PR and NI stand for?
- PR: priority of the process - NI: The nice value of the process. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.
What is SRTF?
- Shortest-Remaining-Time-First Scheduling - Is when SJF is preemptive ... When a new process arrives at the ready queue while a previous process is still executing, the next CPU burst of the newly arrived process may be shorter than what is left of the currently executing process => A preemptive SJF algorithm will preempt the currently executing process
How is the free list used with RAM?
- The OS must maintain data structures keeping track of the usage of every page frame of the physical memory. How this is done is dependent on the OS — below is a simplified description of how Linux does this. -The Linux kernel has an array of page descriptors, one for each page frame in RAM. Which page frame a page descriptor corresponds to is determined by the index of the page descriptor in the descriptor array. Each descriptor contains, among other things, an assortment of flags as well as a reference count governing whether or not the page is free.
What is a write-back cache policy?
- The data is updated only in the cache and updated into the memory at a later time. - Data is updated in the memory only when the cache line is ready to be replaced - cache maximizes the dirty pages needing to be written back
What is wait time?
- The sum of the periods spent waiting in the ready queue - Time from work becoming ready until the first point it begins execution => Loui version
What is latency/response time?
- The time form the submission of a request until the first response is produced; The time it takes to start responding - time from work becoming ready until it is finished in case of batch activity, or until the system responds and hands the first output to the user in case of interactive activity - latency refers to the time delay between when a command is entered and when the data is available
What is the difference between a preemptive SJF and nonpreemptive SJF?
- When a new process arrives at the ready queue while a previous process is still executing, the next CPU burst of the newly arrived process may be shorter than what is left of the currently executing process: - A preemptive SJF algorithm will preempt the currently executing process - A nonpreemptive SJF will allow the currently running process to finish its CPU burst
What is a write-through cache policy?
- Write through is a storage method in which data is written into the cache and the corresponding main memory location at the same time. The cached data allows for fast retrieval on demand, while the same data in main memory ensures that nothing will get lost if a crash, power failure, or other system disruption occurs. - data is simultaneously updated to cache and memory. - Pros: (1) This process is simpler and more reliable. (2) This is used when there are no frequent writes to the cache(The number of write operations is less). It helps in data recovery (In case of a power outage or system failure). (3) It Solves the inconsistency problem. - Cons: (1) A data write will experience latency (delay) as we have to write to two locations (both Memory and Cache). (2) It questions the advantage of having a cache in write operation (As the whole point of using a cache was to avoid multiple access to the main memory). - write modified pages back to disk even though they might be further modified => Loui slide - minimizes the amount of cleaning needed on next demand for memory => Loui slide
What is demand paging?
- a method of virtual memory management - when you load on attempted reference => the OS copies a disk page into physical memory only if an attempt is made to access it and that page is not already in memory (i.e., if a page fault occurs). - It follows that a process begins execution with none of its pages in physical memory, and many page faults will occur until most of a process's working set of pages are located in physical memory. - This is an example of a lazy loading technique
What is an ASID?
- address-space identifiers - stored in each TLB entry - An ASID uniquely identifies each process and is used to provide address-space protection for that process.
What is an ABI?
- application binary interface: an interface between 2 binary program modules - one of these usually being an operating system facility, and the other being a program run by a user
What does BSS stand for?
- block started by symbol - is uninitialized static or global data segment - Objects in the BSS segment have only a name and a size but no value
What is CFS?
- completely fair scheduling/scheduler - CFS aims at dividing CPU time fairly, or equally, among all of the processes. Each process gets a 1/N timeslice (N is the number of processes ready to run);However the 1/N timeslice at the end of each timeslice can change, because N is dynamic. The number of processes contending for CPU time changes as some processes terminate and new ones are made. In CFS, the decision of which process to run next is determined by the vruntime (or virtual runtime) of the process; At the end of each time slice, the process with the lowest vruntime is chosen to run next. Then the next dynamic timeslice is computed.
What is a CAM?
- content-addressable memory - the TLB is CAM - is a type of memory that is high-speed; also called associative memory - Each entry in the TLB consists of two parts: a key (or tag) and a value. When the associative memory (CAM) is presented with an item, the item is compared with all keys simultaneously. If the item is found, the corresponding value field is returned. The search is fast; the hardware, however, is expensive. - basically compares input search data against a table of stored data, and returns the address of matching data
What is DMA?
- direct memory access - a method that allows an input/output (I/O) device to send or receive data directly to or from the main memory, bypassing the CPU to speed up memory operations; a feature of computer systems that allows certain hardware subsystems to access main system memory (random-access memory) independently of the central processing unit (CPU). => DMA process is managed by a chip called the DMA controller - After setting up buffers, pointers, and counters for the I/O device, the device controller transfers an entire block of data directly to or from its own buffer storage to memory, with no intervention by the CPU. Only one interrupt is generated per block, to tell the device driver that the operation has completed, rather than the one interrupt per byte generated for low-speed devices. While the device controller is performing these operations, the CPU is available to accomplish other work.
What is EDF?
- earliest deadline first scheduling - a dynamic priority scheduling algorithm for real time embedded systems. Earliest deadline first selects a task according to its deadline such that a task with earliest deadline has higher priority than others - Since absolute deadline of a task depends on the current instant of time so every instant is a scheduling event in EDF as deadline of task changes with time. => A task which has a higher priority due to earliest deadline at one instant it may have low priority at next instant due to early deadline of another task. - EDF typically executes in preemptive mode (i.e. currently executing task is preempted whenever another task with earliest deadline becomes active.)
What is meant by FIFO?
- first in first out AKA FCFS (first come first serve) scheduling algorithm - The process that requests the CPU first is allocated to the CPU first Implemented with a FIFO queue => When a process enters the ready queue, its PCB is linked onto the tail of the queue. When the CPU is free, it is allocated to the process at the head of the queue. The running process is then removed from the queue - Con = Average wait time is quite long and varies substantially if the processes CPU burst times vary greatly
What is a free list?
- free space list keeps track of the disk blocks that are not allocated to some file or directory - A free list is a data structure used in a scheme for dynamic memory allocation. It operates by connecting unallocated regions of memory together in a linked list, using the first word of each unallocated region as a pointer to the next.
What does (rotating) HDD stand for?
- hard disk drive - physically finds and retrieves data - HDDs rely on spinning disks, or platters, to read and write data => Hard disk drives consist of one or more magnetically sensitive platters, an actuator arm with a read/write head on it for each platter, and a motor to spin the platters and move the arms
What is a HPT?
- hierarchal page table - A page table can get excessively large, thus a solution is to break them up into smaller pieces - hierarchal paging is a paging scheme which consist of two or more levels of page tables in a hierarchical manner. The entries of the level 1 page table are pointers to a level 2 page table and entries of the level 2 page tables are pointers to a level 3 page table and so on. The entries of the last level page table store actual frame information - Each page table entry except the last level page table entry contains base address of the next level page table
What does IPC stand for? What is it?
- interprocess communication: sending data from one process to the next - Cooperating processes (any process that shares data with other processes) require an interprocess communication (IPC) mechanism that will allow them to exchange data and info - There are 2 models of IPC: (1) shared memory and (2) message passing
What does the irq command mean?
- interrupt request: a hardware signal sent to the processor instructing it to suspend its current activity and handle some external event
What is a IPT?
- inverted page table - Problem that IPT solves: Most OSs implement a separate page table for each process (i.e. for 'n' number of processes running, there are 'n' number of page tables stored in the memory). Sometimes when a process is very large in size, it's page table size also increases substantially. Thus, these tables may consume large amounts of physical memory just to keep track of how other physical memory is being used. - What IPT is: Instead of one page table for each process, there is one page table for each frame in physical memory. So the number of page table entries in the Inverted Page Table reduces to the number of frames in physical memory and a single page table is used to represent the paging information of all the processes. Each entry consists of the virtual address of the page stored in that real memory location, with information about the process that owns the page.
How is free list used with malloc?
- keep a linked list of free blocks - In malloc, if the list is not empty, you search for a block large enough to satisfy the request and return it
What is LRU?
- least recently used - is a caching scheme - The LRU caching scheme is to remove the least recently used frame when the cache is full and a new page is referenced which is not there in cache.
What does NUMA stand for?
- non-uniform memory access - A memory access model that happens in multiprocessing where some parts of memory may take longer to access than other parts, creating a performance penalty => Numa penalty can be minimized by OSs through resource management - CPU has faster access to some parts of main memory than to other parts
What does NVRAM stand for?
- non-volatile RAM
What does nTH stand for (in top)?
- nthread: the number of currently active threads of a process
What does PFN stand for?
- page frame number - the frame number in which the current page you are looking for is present
What is a PT?
- page table - stores the mapping between virtual and physical memory addresses - Every address generated the CPU is divided into two parts: (1) page number and (2) page offset. The page number is used as an index into a page table. The page table contains the base address of each page in physical memory. This base address is combined with the page offset to define the physical memory address that is sent to the memory unit.
What is a PTE?
- page table entry - The page table is an array of page table entries. - Each page table entry (PTE) holds the mapping between a virtual address of a page and the address of a physical frame. There is also auxiliary information about the page such as frame number, present bit, dirty bit, etc.
What are huge pages?
- pages that are greater than the default size (4 KB) - pro: Using huge pages means you will need fewer pages. This decreases the number of mapping tables to load by the kernel to a great extent. This increases your kernel-level performance which ultimately benefits your application. Using very large page sizes can improve system performance by reducing the amount of system resources required to access page table entries.
What is a PPID?
- parent process ID => the process ID of the current process's parent
What is a PCB?
- process control block - Each process in the OS is represented by a PCB - Contains info associated with each specific process, such as the following: PID, process state, program counter, priority, CPU registers, CPU scheduling info, memory-management info, accounting info, I/O status info, etc.
What is a PID?
- process identifier - a number used by most operating system kernels to uniquely identify an active process - On 32-bit platforms, 32768 is the maximum value for pid_max
What does RAM stand for?
- random access memory - another word for main memory - it is rewritable
What is RMS?
- rate-monotonic scheduling - a priority algorithm that belongs to the static priority scheduling category: The task with the highest static priority that is runnable immediately preempts all other tasks - It is preemptive in nature. - The priority is decided according to the cycle time of the processes that are involved => If the process has a small job duration, then it has the highest priority. Thus if a process with highest priority starts execution, it will preempt the other running processes. - The priority of a process is inversely proportional to the period it will run for.
What is RTOS?
- real time operating system: a software component that rapidly switches between tasks, giving the impression that multiple programs are being executed at the same time on a single processing core. - usually found in embedded systems => There are well-defined, fixed time constraints, and processing must be done within the defined constraints, or the system will fail
What does the "mys+i" refer to in the malloc code?
- refers to the base address + page offset used during paging
What does a command starting with se. mean?
- se = schedulable entity: a kernel object that can compete for execution time on a system, based on a predefined scheduling algorithm AKA a kernel thread
What does the .so at the end of a command mean?
- shared object: A library that is automatically linked into a program when the program starts, and exists as a standalone file AKA a library that can be used/accessed by more than one process
What does SJF mean?
- shortest job first - Associates with each process the length of the process's next CPU burst. When the CPU is available, it is assigned to the process that has the smallest next CPU burst. If the next CPU bursts of two processes are the same, FCFS scheduling is used to break the tie Scheduling depends on the length of the next CPU burst of a process, rather than its total length - Pros: SJF is optimal in that it gives the minimum average waiting time for a given set of processes => average waiting time decreases - Cons: Difficult to know the length of the next CPU request;Can be used for long-term, but cannot be implemented at the level of short-term scheduling
What does SSD stand for?
- solid state disk - AKA electronic RAM disks - can be volatile or nonvolatile - faster than HDD b/c electronically finds and retrieves data
What is a TLB?
- translation look-aside buffer - is basically a small, fast-lookup hardware cache => a memory cache that is used to reduce the time taken to access a user memory location; a special cache used to keep track of recently used transactions - How it's used in paging: TLB contains page table entries that have been most recently used. Given a virtual address, the processor examines the TLB if a page table entry is present (TLB hit), the frame number is retrieved and the real address is formed. If a page table entry is not found in the TLB (TLB miss), the page number is used as index while processing page table. TLB first checks if the page is already in main memory, if not in main memory a page fault is issued then the TLB is updated to include the new page entry.
What is anticipatory paging?
- type of swapping in virtual memory systems (AKA method of virtual memory management) - prefetch => the OS attempts to anticipate the data that will be needed next and copies it to RAM before it is actually required
What does the strcpy() function do?
- used to copy one string to another - parameters: (1) pointer to the destination array where the content is to be copied, (2) string which will be copied - return value: After copying the source string to the destination string, the strcpy() function returns a pointer to the destination string. - Important points: - it replaces the content of destination string by the content of source string - does not affect the source string
What does a (kernel) watchdog do?
- used to monitor if a system is running - used to automatically reboot hanged systems due to unrecoverable software errors => Watchdog functionality on the hardware side sets up a timer that times out after a predetermined period. The watchdog software then periodically refreshes the hardware timer. If the software stops refreshing, then after the predetermined period, the timer performs a hardware reset of the device.
What does Vaddr stand for?
- virtual address - virtual address in memory is a pointer or marker for a memory space that an operating system allows a process to use. The virtual address points to a location in primary storage that a process can use independently of other processes - a binary number in virtual memory that enables a process to use a location in primary storage (main memory) independently of other processes and to use more space than actually exists in primary storage by temporarily relegating some contents to a hard disk or internal flash drive.
What do the following VMSTAT (virtual memory statistics) mean? 1. (procs) r 2. (procs) b 3. (memory) swpd 4. (memory) free 5. (memory) buff 6. (memory) cache 7. (swap) si 8. (swap) so 9. (io) bi 10. (io) bo 11. (system) in 12. (system) cs 13. (cpu) us 14. (cpu) sy 15. (cpu) id 16. (cpu) wa 17. (cpu) st
1. # of processes waiting for runtime 2. # of processes in uninterruptible sleep 3. amount of virtual memory used 4. amount of idle memory used 5. amount of memory used as buffers 6. amount of memory used as cache 7. swap in: amount of memory swapped in from disk 8. swap out: amount of memory swapped to disk 9. blocks received from a block device 10. blocks sent to a block device 11. # of interrupts 12. # of context switches 13. user time (time spent running non-kernel code) 14. system time (time spent running kernel code) 15. time spent idle 16. time spent waiting for i/o 17. time stolen from virtual machine
When looking at the "%CPU(s)" line TOP, what do the following abbreviations stand for? 1. us 2. sys 3. ni 4. id 5. wa
1. User CPU time - The time the CPU has spent running users' processes that are not niced 2. System CPU time - The time the CPU has spent running the kernel and its processes. 3. Nice CPU time - The time the CPU has spent running users' proccess that have been niced. 4. idle 5. iowait - Amount of time the CPU has been waiting for I/O to complete.
What are the goals of a good CPU scheduling algorithm?
1. maximizing throughput 2. minimizing wait time 3. minimizing latency or response time 4. maximizing fairness
When looking at TOP, what do the following abbreviations stand for? 1. PR 2. NI 3. VIRT 4. RES
1. the process's priority 2. nice value 3. virtual size of a process 4. resident size: the non-swapped physical memory a process has used
What do the following mean in TOP? 1. VIRT 2. RES 3. SWAP 4. DATA 5. nMaj 6. nMin 7. nDRT 8. vMj 9. vMn 10. USED
1. virtual memory size (amount of vm used by the process) 2. resident memory size (non-swapped physical memory a process has used) 3. swapped size (non-resident portion of a process's address space) 4. Data + Stack Size (amount of physical memory devoted to other than executable code) 5. Major Page Fault Count (# of major page faults that have occurred for a task) 6. Minor Page Fault count 7. Dirty Pages Count (# of pages that have been modified since they were last written to auxiliary storage) 8. Major Page Fault Count Delta (# of major page faults that have occurred since the last update) 9. Minor Page Fault Count Delta 10. memory in use
What is systemd-journal?
A system service that collects and stores logging data
What is the first fit solution to how to satisfy a request of size n from a list of free holes?
Allocate the first hole (on the list) that is big enough
What is the worst fit solution to how to satisfy a request of size n from a list of free holes?
Allocate the largest hole that is big enough - we must search the entire list, unless it is sorted by size
What is the next fit solution to how to satisfy a request of size n from a list of free holes?
Allocate the next hole from current pointer in list that is big enough
What is the best fit solution to how to satisfy a request of size n from a list of free holes?
Allocate the smallest hole that is big enough - We must search the entire list, unless the list is ordered by size. This strategy produces the smallest leftover hole.
What is a buddy system?
Buddy allocation system is an algorithm in which a larger memory block is divided into small parts to satisfy the request. This algorithm is used to give best fit. The two smaller parts of block are of equal size and called as buddies. In the same manner one of the two buddies will further divide into smaller parts until the request is fulfilled. Benefit of this technique is that the two buddies can combine to form the block of larger size according to the memory request.
How is the free list used with contiguous memory allocation?
Contiguous allocation (also called "extent-based"): allocate files like segmented memory (contiguous run of sectors). Keep a free list of unused areas of the disk. When creating a file, make the user specify its length, allocate all the space at once. Descriptor contains location and size.
What is a daemon?
Daemon is a program that continuously runs as a background process rather than being under the direct control of an interactive user. It exists for the purpose of handling periodic service requests that a computer system expects to receive.
What is a dirty page?
Dirty pages are the pages in memory (page cache) that have been rationalized and consequently have changed from what is currently stored on disk. This usually happens when an existing file on the disk is altered or appended.
What is a dirty bit?
Each Block in the cache needs a bit to indicate if the data present in the cache was modified(Dirty) or not modified(Clean). If it is clean there is no need to write it into the memory. It is designed to reduce write operation to a memory.
What does a program counter (pc) do?
Indicates the address of the next instruction to be executed for this process
Which fit is better?
Simulations have shown that both first fit and best fit are better than worst fit in terms of decreasing time and storage utilization. Neither first fit nor best fit is clearly better than the other in terms of storage utilization, but first fit is generally faster.
How is the clock algorithm used in LRU page replacement? (answer to how you would use priority in a page replacement algorithm)
Steps: 1. Maintain a circular list of of pages resident in memory 2. Use a clock (or used/referenced) bit to track how often a page is accessed => The bit is set whenever a page is referenced 3. Clock hand sweeps over pages looking for one with a used bit equal to 0 4. Replace pages that haven't been referenced for one complete revolution of the clock
How does paging work?
The basic method for implementing paging involves breaking physical memory into fixed-sized blocks called frames and breaking logical memory into blocks of the same size called pages. When a process is to be executed, its pages are loaded into any available memory frames from their source (a file system or the backing store). The backing store is divided into fixed-sized blocks that are of the same size as the memory frames.
What does vm stand for (i.e. vmacache)?
The kernel uses virtual memory areas to keep track of the process's memory mappings
What is throughput?
The number of processes (AKA work) that are completed per time unit
What is ZRAM?
ZRAM creates a block device in RAM where pages that would otherwise be written to swap (disk/SSD) are instead first compressed, then stored. This allows for a much faster I/O of swap, and also, the data compression provides a significant amount of memory savings.
What is fairness?
equal CPU time to each process, or more generally appropriate times according to the priority and workload of each process
What is the random fit solution to how to satisfy a request of size n from a list of free holes?
explicitly randomize
What does rt stand for (i.e. rt_priority)?
real time - rt in top is a priority value, not a scheduling policy - PR value is stated as "rt". This value actually corresponds to a PR value of -100 (highest priority)
What does systemd mean?
systemd is a system and service manager for Linux operating systems. When run as first process on boot (as PID 1), it acts as init system that brings up and maintains userspace services. Separate instances are started for logged-in users to start their services.
What does the kdevtmpfs mean?
the kernel thread that maintains devtmpfs
What is a cache miss?
when something is looked up in the cache and is not found - the cache did not contain the item being looked up
What is a cache hit?
when you look something up in a cache and it was storing the item and is able to satisfy the query