Operating Systems - Part II

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Define and contrast the terms resident set and working set.

Resident set: The set of pages of a process that are resident in main memory. Working set: The set of pages that a process needs to have in main memory to run without page faults, for some time interval. The formal definition is the set of pages that a process references during the time window The process will have no page faults as long as the working set is the same as the resident set.

Please explain 1) Belady's anomaly, and discuss (2) if LRU and FIFO have this phenomenon. You do not need to provide "proofs", just an explanation (no explanation, no points).

Belady's anomaly: Increasing the number of frames always decreases the number of page faults for a particular reference string, but this phenomenon states that # of page faults will increase. b. LRU: no. Belady's anomaly states that it is possible to have more resources, and worse access behavior. FIFO: yes. Belady's anomaly does not apply to stack based algorithms.

Suppose the virtual memory has 8 pages with 512 bytes per page, and physical memory with 16 page frames. a. How many bits is the virtual address? b. How many bits is the physical address? c. Given the following page table, what is the physical address corresponding to the virtual address of page 4, byte 241?

a. 2^3 pages number and 2^9 page offset.Virtual address bits are 3+9 = 12 b. 2^4 frame number and 2^9 page offset. Physical address bits are 4+9 = 13 c. binary physical address = 0 0110 1111 0001 so, physical address = 3 * 512 + 241 = 1777

Please explain device drivers and device controllers in short.

a. A device driver is the software component of the operating system that manages detailed interactions with the device. Each device driver provides a common interface to the kernel of the operating system, so it is a translator between the operating system and applications, and use the devices. b. A device controller consists of the electronic interface between a device and the computer system. The controller physically connects the device to the computer system's bus. Provide a device-independent block size

Please describe any three differences between internal and external fragmentation

a. Basic different definitions - internal: a difference between required memory space vs allocated memory space; externel: there are small and non-contiguous memory blocks which cannot be assigned to any process. b. Different memory block size - internal: allocate fixed sizes of memory blocks; external: allocate various sizes of memory blocks c. Different solved solution - internal: best-fit; external: compaction d. Different occurrences - internal: occurs when a process needs more space than the size of allocated memory block (or uses less space); external: occurs when a process is removed from the main memory e. Process - internal: occurs when executing paging; external: occurs when executing segmentation

Discuss how the following pairs of scheduling criteria conflict in certain settings. (10%) (1). CPU utilization and response time (2). Average turnaround time and maximum waiting time (3). I/O device utilization and CPU utilization

a. CPU utilization is increased if the overheads associated with context switching is minimized. The context switching overheads could be lowered by performing context switches infrequently. This could however result in increasing the response time for processes. b. Average turnaround time is minimized by executing the shortest tasks first. Such a scheduling policy could however starve long-running tasks and thereby increase their waiting time. c. CPU utilization is maximized by running long-running CPU-bound tasks without performing context switches. I/O device utilization is maximized by scheduling I/O-bound jobs as soon as they become ready to run, thereby incurring the overheads of context switches.

Assume you are a system administrator of a company and found two usage peaks between 11:30AM to 3:30PM and between 8:30PM to 11:30PM. Your boss asks you to design a system where during these peak hours there will be three levels of users as follows: the users in level 1 can enjoy better response time than the users in level 2, who in turn will enjoy better response time than the users in level 3. Your system can allow all users to still get some progress, but with the indicated preference in place. (10%) (1). If we use a fixed priority scheme with preemption and set the levels as the three priorities, does this scheme can work? Defend your answers.

a. Cannot work. A fixed priority scheme can cause starvation. The required solution should enable all users to make progress. Fixed priority does not guarantee progress for processes with low priorities. b. May not work. The multi-feedback queuing system will cause processes in level 1 to get less time on the CPU if they stay in the system for very long. Therefore, even if a level 1 process may start at the highest level in the feedback queue, its priority will degrade over time. So, this solution does not satisfy the requirements.

What is the cause of thrashing? How does the system detect thrashing? Once it detects thrashing, what can the system do to eliminate this problem?

a. Caused by under allocation of the minimum number of pages required by a process, forcing it to continuously page fault. b. Evaluate the level of CPU utilization as compared to the level of multiprogramming.

To prevent deadlock, we must impose restrictions on processes and resource usage so that deadlocks are structurally impossible. Please explain how to break the four conditions to prevent deadlock.

a. No mutual exclusion: make resources sharable, but some resources cannot work. b. No Hold and wait: i. All processes would need to request all resources before they begin execution. ii. Processes must give up resources if a new request would block. c. Preemption: if a thread requests a resource that cannot be immediately allocated to it, then the OS preempts all the resources the thread is currently holding. Only when all the resources are available will the OS restart the thread d. No circular wait: i. Assign each resource a unique numeric code. ii. Processes must request resources in increasing order of their numeric codes.

Under what circumstances do page faults occur? Describe the actions taken by the operating system when a page fault occurs.

a. Occurs when an access to a page that has not been brought into main memory takes place. b. OS requests interrupt, verifies the memory access, aborting the program if it is invalid (e.g., memory illegal access or page faults). (1). If page faults, check if pages in memory. If not, execute page replacement algorithm (2). A free frame is located and I/O is requested to read the needed page into the free frame. (3). Upon completion of I/O, the process table and page table are updated and the instruction is restarted.

Describe three ways for the OS typically to communicate with I/O devices through their controllers.

a. Polling (Busy waiting I/O): OS keeps checking until the status of the I/O device is idle. b. Interrupts: Rather than have the CPU continually check if a device is available, the device can interrupt the CPU when it completes an I/O operation. c. Direct Memory Access (DMA): DMA devices manage data transfers between the controller and the system's primary memory independent of the CPU (once the transfer has been set up).

What are RAID disks? What are RAM disks?

a. Redundant Array of Inexpensive Disks: A data storage technique. To achieve a performance increase, two disks could be used in parallel, with the data in corresponding blocks on each disk treated as a single larger block, but allowing the transfer of data in parallel. b. A RAM disk is just a region of primary memory made to function like a small disk. It does not exhibit persistence (like SSD drives).

What is Inverted Page Table (IPT)? When does a virtual memory system need to use the IPT? What is the difference between inverted and hashed page tables?

a. Since processes share physical memory, we need a single global page table to record if this page in physical memory is free. If allocated, each entry must contain the process ID of the page owner <virtual page #, process_id>, and table indexed by physical page number. b. When page table size is too big. c. Inverted: Contains one entry per physical frame as opposed to one for each virtual page as in the case of standard page tables. This makes it much smaller compared to standard page tables. However, the lookup time can be very high, because the whole table has to be linearly searched. Hashed: maintains a hash-table of virtual-to-physical translations, containing a mapping of process ID and virtual page number to page table entries, and uses separate chaining for collisions. This makes it much smaller compared to standard page tables. Lookup in hash table for page table entry, compare process ID and virtual page number. If match, then found; if not a match, check the next pointer for another page table entry and check again. The lookup is much faster compared to inverted tables: typically 1 or 2 accesses.

Consider a paging system and we add associative registers TLB for caching (15%) a. Please define spatial locality and temporal locality. b. Disk manufacturers added a full track buffer to hard drives to improve program performance. Which of spatial or temporal locality most motivated this? Explain your answer. c. Hardware caches in the memory hierarchy are other performance enhancing techniques. Explain how/why spatial locality and temporal locality contribute to this performance enhancement.

i. Spatial locality means the access to a data item makes near-future accesses to spatially nearby data items more likely. Temporal locality means the access to a data item makes another access to the same data item in the near future more likely. ii. Spatial locality. Access to one data block makes near-future accesses to other blocks on the same track more likely. Additionally temporal locality is already exploited by the operating system's file buffer cache iii. The concept of caching recently accessed data items is motivated by temporal locality. The fact that a cache line (32 or 64 bytes) is usually larger than what an instruction needs is motivated by spatial locality.

What is virtual memory?

Virtual Memory: a storage allocation scheme where secondary memory can be addressed as though it were part of main memory.

Please describe any two differences and similarities between Paging and Segmentation in short.

a. Differences: i. A page is of fixed block size v.s. A segment is of variable size ii. Internal fragmentation v.s. External fragmentation iii. Use specified address is divided by CPU into a page and offset v.s the user specifies each address by a segment number and the offset (segment limit) iv. The hardware decided the page size v.s. Specified by the user v. Page table (contain base address of each page) v.s. Segment table (segment number and offset(segment length)) b. Similarities: HW support, support memory sharing and protection, the procedure from logical address to physical address, support dynamic linking and loading.

Please briefly describe (1) any two difference between starvation and deadlock and (2) explain how to prevent starvation.

a. Different: Deadlock is where no process proceeds and get blocked. Starvation is where low priority processes get blocked, and high priority processes proceed. b. Different: Deadlock, requested resources are blocked by the other processes. Starvation, the requested resources are continuously used by high priority processes. c. Different: Deadlock, circular wait. Starvation lock forever. d. Prevention: Aging.

The performance of the Round Robin scheduling depends heavily on the size of the quantum. (8%) (1). Please given an argument against too small and large sizes of quantum (2). Can the Round Robin scheduling lead to starvation? Defend your answer.

a. If the quantum is too short, most of the processor time is spent doing context switching between processes. CPUs always switch in/out, so throughput is very low. If the quantum is too long, then process response time is compromised (becomes FCFS). A process can compute for essentially as long as it wishes. b. No. All processes/threads will take turns in a queue; a job will be selected from the front and put it the back of the queue.

Scheduling is to select the jobs to be submitted into the system and to decide which process to run. Please briefly describe long-term scheduler, medium-term scheduler, and short-term scheduler.

a. Long-term scheduling: The decision to add to the pool of processes to be executed, loading from the disk to memory. b. Medium-term scheduling: The decision to add to the number of processes that are partially or fully in main memory to increase the system performance (swap out-processes, e.g., overloaded processes). c. Short-term scheduling: The decision as to which available process will be executed by the processor; a process among the processes that are ready to execute and allocates CPU to one of them.


Ensembles d'études connexes

Pharm: Chapter 47: Lipid-Lowering Agents PREP U

View Set

English4IT Vocabulary Units 1-25

View Set

PERFORMANCE OBJECTIVES FOR LAB 1

View Set

MW SCOM 122 FINAL EXAM STUDY GUIDE

View Set

Project 3: Museum Image Correction

View Set

영어패턴233-패턴(1,3) 17-32

View Set