:mortar_board: Sunway University BSc in CS notes :memo: (201701 intake)
Lecturer: Dr Chia Wai Chong
Textbook used: Operating System Concepts, 9th Edition by Gagne, Galvin, Silberschatz. Wiley & Sons
Why is main memory not suitable for permanent storage or backup purposes? Furthermore, what is the main disadvantage to store information on a magnetic disk drive as opposed to main memory?
Identify TWO advantages and TWO disadvantages of open-source operating systems (eg. Linux).
Explain why an operating system can be viewed as a resource allocator.
What are the TWO fundamental approaches for users to interface with the operating system? Discuss, from your point-of-view, which approach is better.
Describe the CPU’s two modes of operation (user mode and kernel mode).
What are the main factors that a programmer would take into consideration when designing an operating system for a smart TV?
There are TWO different ways that commands can be processed by a command-;ine interpreter. One way is to allow the command interpreter to contain the code needed to execute the command. The other way is to implement the commands through system programs. Compare and contrast the two approaches.
What is the advantage and disadvantage of the microkernel approach when compared to the monolithic approach?
What is a dynamically loadable module?
Describe FOUR advantages of using a virtual machine?
What is the difference between a Type 1 hypervisor and a Type 2 hypervisor?
Compare and contrast the TWO inter-process communication models?
What is the main factor that must be taken into consideration when processes communicate using the shared-memory model?
If a synchronous type of communication is required, what is the requirement that should be imposed on the sender and the receiver in the message-passing model?
What is the main difference between multi-programming and time-sharing in terms of execution?
Is it possible to implement both multi-programming and time-sharing techniques into an operating system and having them running simultaneously? If YES, explain how it could be done. If NO, explain why it is not possible and justify your answer.
Describe the characteristics of short-term scheduler, medium-term scheduler, and long-term scheduler.
Question 1
Process | Arrival Time (ms) | Burst Time (ms) | Priority* |
---|---|---|---|
P1 | 0 | 15 | 5 |
P2 | 3 | 2 | 1 |
P3 | 4 | 6 | 3 |
P4 | 8 | 2 | 4 |
P5 | 12 | 10 | 2 |
*Note: Smaller number, higher priority
Draw four Gantt charts that illustrate the execution of these processes using the FCFS, SJF, Preemptive Priority, and RR (quantum = 2 ms) scheduling algorithms.
Determine the turnaround time of each process for each of the scheduling algorithms in part (a). Also, calculate the average turnaround time.
Determine the waiting time of each process for each of the scheduling algorithms in part (a). Also, calculate the average waiting time.
Question 2
Process | Arrival Time (ms) | Burst Time (ms) | Priority* |
---|---|---|---|
P1 | 0 | 6 | 2 |
P2 | 3 | 5 | 1 |
P3 | 4 | 2 | 3 |
P4 | 8 | 4 | 5 |
P5 | 12 | 9 | 4 |
*Note: Smaller number, higher priority
Draw four Gantt charts that illustrate the execution of these processes using the FCFS, SJF, Preemptive Priority, and RR (quantum = 2 ms) scheduling algorithms.
Determine the turnaround time of each process for each of the scheduling algorithms in part (a). Also, calculate the average turnaround time.
Determine the waiting time of each process for each of the scheduling algorithms in part (a). Also, calculate the average waiting time.
Question 3
Process | Arrival Time (ms) | Burst Time (ms) | Priority* |
---|---|---|---|
P1 | 0 | 2 | 4 |
P2 | 1 | 1 | 2 |
P3 | 3 | 7 | 5 |
P4 | 8 | 2 | 1 |
P5 | 10 | 3 | 3 |
*Note: Smaller number, higher priority
Draw four Gantt charts that illustrate the execution of these processes using the FCFS, SJF, Preemptive Priority, and RR (quantum = 2 ms) scheduling algorithms.
Determine the turnaround time of each process for each of the scheduling algorithms in part (a). Also, calculate the average turnaround time.
Determine the waiting time of each process for each of the scheduling algorithms in part (a). Also, calculate the average waiting time.
Describe the relationship between threads and processes.
A process, which has its own memory space, is like a container for the threads. The threads share that memory space and they are the units of execution within the process. Each thread has its own set of registers, stack, and program counter.
If an application or function needs to be implemented as a set of related units of execution, why is it more efficient to do so as a collection of threads rather than a collection of separate processes?
Describe the FOUR conditions that must hold simultaneously for a deadlock to occur.
What is the difference between deadlock prevention and deadlock avoidance.
Given a set of active processes (P), a set of resources in a computer system (R), and a set of edges (E):
P = {P1, P2, P3}
R = {R1, R2, R3, 2 x R4}
E = {P1->R1,R4->P1,R3->P3,P3->R2,R2->P2,P2->R3,P3->R4}
If a resource can only be accessed by one process at a time, and a resource cannot be preempted, explain whether the computer system is in the deadlock state. You may assume that a process is in the running state if it is not requesting nor waiting for other resources.
Given FIVE memory partitions of 200 KB, 400 KB, 100 KB, 300 KB, and 700 KB (in order). How would each of the first-fit, next-fit, best-fit, and worst-fit algorithms place processes of 256 KB, 117 KB, 412 KB, and 226 KB (in order)?
Partition \ Fit | First-Fit | Next-Fit | Best-Fit | Worst-Fit |
---|---|---|---|---|
256 KB | 400KB (114KB) | 400KB (144KB) | 300KB (44KB) | 700KB (444KB) |
117 KB | 200KB (83KB) | 144KB (27KB) | 200KB (83KB) | 444KB (327KB) |
412 KB | 700KB (288KB) | 700KB (288KB) | 700KB (288KB) | Wait |
226 KB | 300KB (74KB) | 288KB (62KB) | 288KB (62KB) | 400KB (174KB) |
Given FIVE memory partitions of 600 KB, 400 KB, 300 KB, 200 KB, and 100 KB (in order). How would each of the first-fit, next-fit, best-fit, and worst-fit algorithms place processes of 100 KB, 438 KB, 202 KB, and 337 KB (in order)?
Partition \ Fit | First-Fit | Next-Fit | Best-Fit | Worst-Fit |
---|---|---|---|---|
100 KB | 600KB (500KB) | 600KB (500KB) | 100KB (0KB) | 600KB (500KB) |
438 KB | 500KB (62KB) | 500KB (62KB) | 600KB (162KB) | 500KB (62KB) |
202 KB | 400KB (198KB) | 400KB (198KB) | 300KB (98KB) | 400KB (198KB) |
337 KB | Wait | Wait | 400KB (63KB) | Wait |
Suggest a way to reduce external fragmentation and briefly explain the drawback of your suggestion.
Dynamic partitioning can reduce external fragmentation, but the drawbacks would be that it is time consuming. Dynamic partitioning has 4 searching and placement algorithms that can be considered when processes are shifted - first fit, next fit, best fit, worst fit.
What is paging and why is is better than dynamic partitioning?
Paging is when processes are moved to the secondary storage device instead of keeping it in the primary temporary storage. No external fragmentation when paging is used.
Describe page fault and explain how it will be handled.
Page faults are when a running program tries to access a memory page that is not currently mapped by the memory management unit (MMU) into the virtual address space of a process. The steps the operating system takes to fix a page fault are:
Describe the relationship between demand paging and page fault.
Demand paging is a type of virtual memory management, where the OS only copies a disk page when a process makes an attempt to access it. Page fault will result in demand paging, as the OS is unable to find the page, therefore causing demand paging to occur (searching for the page only when attempts to access it occurs).
Instead of using demand paging, do you think it is a good idea to preload/prefetch the pages of a process into the main memory before they are accessed? Justify your answer.
Yes, it is a good idea because modern computers often have large amounts of RAM, and thus will most likely have enough free RAM to store preloaded and prefetched pages. This can help save time and also make the computer faster, as the RAM is much faster than secondary storage.
What are the advantages and disadvantages of using a smaller page size when compared to a larger page size?
Advantages:
Disadvantages:
Consider a process 4GB virtual and physical address space. If the page size in such a system is 4KB, calculate the amount of physical memory space that is required to store the page table of the process. You can assume that 4B of memory is required to store an entry in the page table.
What is a translation lookaside buffer (TLB) ?
A translation lookaside buffer (TLB) is a memory cache that is used to reduce the time taken to access a user memory location. It is a part of the chip’s memory-management unit (MMU). The TLB stores the recent translations of virtual memory to physical memory and can be called an address-translation cache.
A system using dynamic partitioning has five empty memory partitions of 300KB, 200KB, 500KB, 250KB, and 700KB (in order). Determine how would each of the first-fit, next-fit, best-fit, and worst-fit algorithms place processes of 128KB, 100KB, 398KB, and 493KB (in order)?
Question 1
Based on the distribution shown in Figure 1, answer the following questions
If bitmap is used to manage the free space, illustrate how the free-space list wouldlook like.
001110
000111
000000
111100
000111
100000
Assuming that contiguous allocation is adopted, determine the location where the following files can be allocated using first-fit and worst-fit algorithms respectively.
Fit\File | File A | File B | File C |
---|---|---|---|
First fit | 0-1 | 5-7 | 12-17 |
Worst fit | 12 -13 | 31-35 | x |
If a file system could allocate 4KB of disk space as a single 4KB block, determine the number of blocks that is required to store a file with the size of 29KB
If the file system allows disk space to be allocated at different levels of granularity, for instance, the file system could allocate 8KB of disk space as a single 8KB block, or as eight 1KB sub-blocks. How would a file size of 29KB be stored in this case?
Do you think the feature in Question 1(d) could improve the performance? Explain your answer.
Describe how bitmap can be used to manage the free space when the feature in Question 1(d) is implemented.
Compare bitmap and linked-list
Question 2
Based on the distribution showed in Figure 2, answer the following questions.
Suggest TWO (2) allocation methods that can successfully allocate a file with the size of 8 blocks. Justify your answer.
If a file system could allocate 8KB of disk space as a single 8KB block, determine the number of blocks that is required to store a file with the size of 50KB, by using TWO (2) allocation methods suggested in part (a) respectively. State clearly any assumption(s) that you have made.
Sketch TWO diagrams to show the allocation of blocks, based on the TWO (2) allocation methods suggested in part (a) and part (b). Also indicate how the directory would have stored the entry for the file in each allocation method.
Give an example where using a larger allocation size (cluster size) could be better.
What is the difference between a clustered system and a distributed system?
Clustered System | Distributed System |
---|---|
Small scale | Medium - large scale |
Homogenous system (same hardware) | Heterogeneous (different hardware/computer) |
Closely-coupled | Loosely-coupled |
For very specific tasks | General purpose |
Describe THREE (3) challenges in the design of distributed operating systems.
An operating system is using the access control matrix to control the access to resources in a computer system. The associated matrix is shown in Table 1.
File A | Process B | Printer C | |
---|---|---|---|
Jack | Read, Write | Execute | Start Print, Stop Print |
Kim | Read | Execute | |
Alice | Read | Start Print, Stop Print |
Is Alice allowed to execute process B?
If the access permission of “Alice” is removed, illustrate how the access control matrix would look like.
File A | Process B | Printer C | |
---|---|---|---|
Jack | Read, Write | Execute | Start Print, Stop Print |
Kim | Read | Execute |
If a new user “Ken”, which has the same access permission as “Kim” is added, illustrate how the access control matrix would look like.
File A | Process B | Printer C | |
---|---|---|---|
Jack | Read, Write | Execute | Start Print, Stop Print |
Kim | Read | Execute | |
Ken | Read | Execute |
If a role-based access control is used, illustrate how the access control matrix would look like.
Jack | Kim | Alice | Ken | |
---|---|---|---|---|
Admin | X | |||
No Printing | X | X | ||
No Program Execution | X |
File A | Process B | Printer C | |
---|---|---|---|
Admin | Read, Write | Execute | Start Print, Stop Print |
No Printing | Read | Execute | |
No Program Execution | Read | Start Print, Stop Print |
Consider a system in which computer games can be played by students only between 10PM - 6AM, and by faculty members between 5PM - 8AM. Suggest a scheme for implementing this policy efficiently.
Describe ONE difference between access control lists and capability lists.
Briefly explain the concept of one-way hash funciton and the use of it in password protection.
What is the purpose of using a ‘salt’ along with the user-provided password?
A password may become known to other users in a variety of ways. Suggest a simple method for detecting that such an event has occurred.