360 likes | 474 Views
Operating Systems Clicker Questions. Kevin Webb & Cynthia Taylor. The operating system kernel…. Executes as a process Is always executing, in support of other processes Should execute as little as possible More than one of the above. Why shouldn’t processes control context switching?.
E N D
Operating SystemsClicker Questions Kevin Webb & Cynthia Taylor
The operating system kernel… • Executes as a process • Is always executing, in support of other processes • Should execute as little as possible • More than one of the above
Why shouldn’t processes control context switching? • It would cause too much overhead • They could refuse to give up the CPU • They don’t have enough information about other processes
Which CPU scheduling policy is the best? • Processes keep CPU until done (maximize throughput) • Processes use a fraction of CPU and pass it on (ensure fairness) • Processes receive CPU in proportion to their priority or what they pay (prioritize importance) • Other (explain)
Which is true of round-robin schedules relative to first-come first-served. • Round-robin requires knowledge of process run times. • Round-robin schedules have lower average turnaround times. • Round-robin schedules have higher average turnaround times. • Round-robin has higher overhead. • More than one of these
Multi-level feedback queues will naturally prioritize… • Compute-bound processes • I/O-bound processes • Long-running processes • Short processes
Which component of a process might we replicate to take advantage of multiple CPUs? • The address space (memory) • OS resources (open files, etc.) • Execution state (PC, SP, registers, etc.) • More than one of these • Some other component(s)
If you call thread_create() on a modern OS (Linux/Mac/Windows), which type of thread would you expect to receive? (Why? Which would you pick?) • Kernel thread • User thread • Some other sort of thread
For processes (or threads) to communicate, we must have: • a data transfer mechanism • a synchronization mechanism • either synchronization or data transfer • both synchronization and data transfer
/* NO SHARED MEMORY */ Producer int item; while (TRUE) { item = Produce (); send (Consumer, &item); } Consumer int item; while (TRUE) { receive (Producer, &item); Consume (item); } Suppose we’re using message passing, will this code operate correctly? • No, there is a race condition. • No, we need to protect item. • Yes, this code is correct.
/* NO SHARED MEMORY */ Producer int item; while (TRUE) { item = Produce (); send (Consumer, &item); } Consumer int item; while (TRUE) { receive (Producer, &item); Consume (item); } This code is correct and relatively simple. Why don’t we always just use message passing (vs semaphores)? • Message passing copies more data. • Message passing only works across a network. • Message passing is a security risk. • We usually do use message passing!
Which of these conditions is easiest to give up to prevent deadlocks? • Mutual exclusion (make everything sharable) • Hold and wait (must get all resources at once) • No preemption (resources can be taken away) • Circular wait (total order on resource requests) • I’m not willing to give up any of these!
Given the following table, for which values of X, Y, and Z, is this a safe state in the Banker's Algorithm? • X = 3, Y = 1, Z = 1 • X = 2, Y = 0, Z = 2 • Both of these are safe states • Neither of these are safe states
Which type of deadlock-handling scheme would you expect to see in a modern OS (Linux/Windows/OS X) ? • Deadlock prevention • Deadlock avoidance • Deadlock detection/recovery • Something else
Which form of fragmentation is easiest for the OS to reduce/eliminate? • Internal fragmentation • External fragmentation • Neither
Which memory allocation algorithm leaves the smallest fragments (external)? • first-fit • worst-fit • best-fit
Where would worst-fit place this memory chunk? 5 MB A. 5 MB 7 MB B. 9 MB C.
How would the buddy system allocate the following set of requests? Assume 8 MB free initially. 8 MB 4 MB 4 MB Alloc 3 MB, Alloc 1.5 MB, Alloc 1 MB 2 MB 2 MB 8 MB 8 MB 3 MB 5 MB B. 4 MB 4 MB 2.5M 2.5M 2 MB 2 MB C. 1.5M 1 MB A. 1MB 1 MB
Given what we currently know about memory, what must we do during a context switch? • Allocate memory to the switching process • Load the base and bound registers • Convert logical to physical memory addresses
Segment Address Translation • Physical address of ? A. 8000 B. 9200 C. Error 2 1200
5 bit segment address, 32 bit logical address, 1 GB Physical memory.How many entries will we have in our segment table? • 32: The logical address size is 32 bits • 32: The segment address is five bits • 30: We need to address 1 GB of physical memory
Which of these would be true about a multi-level page table, compared to a single-level page table? • Multi-level usually uses less memory. • Multi-level usually has faster lookup times. • Both cause the same amount of fragmentation. • More than one of the above is true.
A page fault occurs. What must we do in response? • Find the faulting page on disk. • Evict a page from memory and write it to disk. • Bring in the faulting page and retry the operation. • Two of the above • All of the above
Handing faults from disk seems very expensive. How can we get away with this in practice? • We have lots of memory, and it isn’t usually full. • We use special hardware to speed things up. • We tend to use the same pages over and over. • This is too expensive to do in practice!
Your closet is full, but you just got a new shirt. How do you make room for it in your closet? • Throw out another shirt at random. • Throw out your newest shirt. • Throw out your oldest shirt. • Throw out a shirt you haven’t worn for a while. • I govern my closet with some other shirt replacement policy.
Which is true of the Clock algorithm? • Clock will always have fewer faults than FIFO. • Clock will always have the same fault count as LRU. • Clock will always have more faults than Optimal. • More than one of the above. • None of the above.
Why are disks slow? • We have to move a disk head. • We have to spin the disk platters. • Disk data is farther away from the CPU/Mem. • More than one of these. • All of these.
Regarding file types… • The OS distinguishes between file types. • The user distinguishes between file types. • Both the OS and users distinguish between file types. • Nobody distinguishes between file types, files are all just files.
Which of the following is commonly represented by a file? • A mouse • A link to another file • A directory • More than one of the above • All of the above
A file’s “path” determines where it is stored on a disk device. • True • False • Sometimes
Why do we have an open() call, as opposed to just read()ing orwrite()ing a file path? • To check file permissions • To improve performance • To lookup the file’s location on disk • Two of the above • All of the above
For a memory mapped file… • The entire file must be in memory. • Pages are brought in as accessed. • All pages will eventually be written back to disk. • More than one of the above.
Which allocation strategy has the smallest space overhead? Easiest to resize a file?
Suppose a block is 1 KB (210 bytes). How many pointers do we need in our block map to support a maximum file size of 16 GB (234 bytes)? A: 210 B: 216 C: 224 D: 234 E: Some other number of pointers Block size: 1 KB … ?
What about writes? What if we lose power, and our modified data is only in memory? When should we write it to the disk to maintain reliability? • Write blocks to disk immediately, to ensure safety. • Write blocks when we evict them from the cache, to maximize performance. • Write blocks when the user explicitly tells us to, since the user/application knows best. • Write blocks to disk at some other time.