OS MIDTERM
6.4 Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. In answering the questions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made AT = Arrival time BT = Burst Time P1-> AT 0.0 ->BT 8 P2-> AT 0.4 ->BT 4 P3-> AT 1.0 ->BT 1 A. What is the average turnaround time for these processes with the FCFS scheduling algorithm? B. What is the average turnaround time for these processes with the SJF scheduling algorithm? C. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may increase. This algorithm could be known as future-knowledge scheduling.
Average turn around time FCFS: (8+11.6+12)/3 = 10.5333 SJF:8+12.6+8 = 9.5333 C: (14 + 5.6 + 1) / 3 = 6.866
2.8) The following is a list of operations that are normally protected. What is the minimal set of instructions that must be protected? A. Change to user mode. B. Change to monitor mode. C. Read from monitor memory. D. Write into monitor memory. E. Fetch an instruction from monitor memory. F. Turn on timer interrupt. G. Turn off timer interrupt
B. Change to monitor mode (anyone can get privileged access if not protected) D. Write into monitor memory (Any process can change memory data if not protected) G. Turn off timer interrupt (stops processes from running forever)
1.6 Define the essential properties of the following types of operating systems: A. Batch
Batch: similar Jobs grouped together
6.9 Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor I/O-bound programs and yet not permanently starve CPU-bound programs?
CPU bound programs can run while I/O waits for response i.e input.
1.6 Define the essential properties of the following types of operating systems: C. Time Sharing
CPU time is shared among many users, more users there are the longer the response time.
2.9 Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?
Caches allow for fast memory access. They have the potential problem of being values in cache being inconsistent with what is actually in Main memory if not handled properly. Cache is expensive so we cannot make it as large as the device. Plus when its that large it becomes redundant
4.1 MS-DOS provided no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system
Concurrent processing adds Resource allocation, synchronization and deadlocks.
4.4 Describe the actions a kernel takes to context switch between processes.
Context switching between kernel threads typically requires saving the value of the CPU registers from the thread being switched out and restoring the CPU registers of the new thread being scheduled.
For what types of operations is DMA useful? Explain your answer
DMA is useful for transferring large quantities of data between memory and devices. It eliminates the need for CPU thus speeding up the process and allowing the CPU to do other things.
2.10 Writing an operating system that can operate without interference from malicious or undebugged user programs requires some hardware assistance. Name three hardware aids for writing an operating system, and describe how they could be used together to protect the operating system.
base register: acts as an address holder for the base storage location limit register: helps define he length of the address space. OS protection through privileges : The use of privileged instructions for allowed users.
What is the algorithm that results from β > α > 0?
first come first serve
How to create a pipe?
int p[2] pipe(p)//both parent and child have same file decriptors must do before fork pid = fork() if(pid<0) //error if(pid>0){ //parent close(1) dup(p[1])//redirect output of p1 to input of p[0] close(p[1])//close after you finish dup close(p[0])//close since you dont need }else{ //child close(0) dup(p[0]) close(p[0]) close(p[1]) }
What is the algorithm that results from α < β < 0?
last in first out.
4.3 A DECSYSTEM-20 computer has multiple register sets. Describe the actions of a context switch if the new context is already loaded into one of the register sets. What else must happen if the new context is in memory rather than in a register set and all the register sets are in use?
lets say we are trying to switch from process P0 to P1 we save the context of P0 into PCB0 located in main memory and and load the context of P1 from PCB1 located in main memory. If all register sets are in use then we save the register sets to main memory and wipe them so we can store new contexts into the register sets.
3.16 Discuss the pros and cons of the Synthesis approach to kernel design and to system performance optimization.
synthesis layers more secure, no layers opposite. layers longer response time, no layers shorter response time. layer easier to debug, no layer harder to debug
Describe Fault Tolerance and how to find fault tolerance degree
How much a system can handle in the case of a fault. Fault tolerance degree is calculated by the number of cpus -1. If there are 4 cpus then the fault tolerance degree is 3 meaning 3 cpus can go down with out compromising the whole system.
3.12 What are the main advantages of the microkernel approach to system design?
It is easier to update/modify a micro kernel because it is smaller
2.6 Some computer systems do not provide a privileged mode of operation in hardware. Consider whether it is possible to construct a secure operating system for these computers. Give arguments both that it is and that it is not possible
It is possible because anything that is not implemented in the hardware can be implemented in the OS
3.2 What are the three major activities of an operating system in regard to memory management?
Keep track of memory that is currently being used. Decide which process can or should be loaded into an available space. Allocate and deallocate memory space as needed.
3.10 What is the purpose of system programs?
Similar to system calls but, They are a bundle of system calls. They have the same purpose which is to get a service from the OS.
3.4 What are the five major activities of an operating system in regard to file management?
1. Creation and deletion of files. 2.Creations and deletions of directions. 3.support of primitives for manipulation files and directions. 4. Mapping of files onto secondary storage. 5.File back up.
3.3 What are the three major activities of an operating system in regard to secondary-storage management?
1.Free space management 2.storage allocation 3.disk scheduling
1.1 What are the three main purposes of an operating systems?
1.Provide a kernel 2. Allocate resources 3. Supervision of execution and managing I/O
2.5 Which of the following instructions should be privileged? A. Set value of timer. B. Read the clock. C. Clear Memory. D. Turn off interrupts. E. Switch from user to monitor mode.
A. Set value of timer C. Clear Memory D. Turn off interrupts E. Switch from user to monitor mode
1.5 In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems. A. What are two such problems? B. Can we ensure the same degree of security in a time-shared machine as we have in a dedicated machine? Explain your answer.
A.1 Users can access other users info (shared memory) A.2 Users can access other users space B. No. Security Algos are designed by people and can eventually be broken by people
6.5 Consider a variant of the RR scheduling algorithm where the entries in the ready queue are pointers to the PCBs. A. What would be the effect of putting two pointers to the same process in the ready queue? B. What would be the major advantages and disadvantages of this scheme? C. How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?
A.Higher priority processes would get selected more. B.Higher priority items get more time to process, lower priority items get less time. C. Just spend more time on higher priority.
6.10 Explain the differences in the degree to which the following scheduling algorithms discriminate in favor of short processes: A. FCFS B. RR C. Multilevel feedback queues
A: No favor B: Favors shorter jobs will tend to finish first C. MLFQ: Yes usually but depends on the algorthims used to move processes in the Q's
6.8 Identify the relationships between the following pairs of algorithims A. Priority and SJF B. Multilevel feedback queues and FCFS C. Priority and FCFS D. RR and SJF
A: The job with the shortest time has the highest priority and so forth. B: The lowest level of a MLFQ is FCFS C: The Priority increases in terms of the order that they came in. The highest priority is given to the first item. D: None
1.3 Main advantage of multiprogramming?
Ability to load more than one job into the system.
1.6 Define the essential properties of the following types of operating systems: E. Network
Communication between computers is used to exchange data
3.13 What is the main advantage for an operating-system designer of using a virtual-machine architecture? What is the main advantage for a user?
For user :Lets you run any program on any machine because the VM can be installed on any machine. For designer: It is more secure because the hardware has the VM layer on top.
6.3 Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: BT= burst time. P1->BT 10->Priority :3 P2->BT 01->Priority :1 P3->BT 02->Priority :3 P4->BT 01->Priority :4 P5->BT 05->Priority :2 Give the order for FCFS,SJF, nonpreemptive priority and RR(quantum = 1). B. What is the turnaround time of each process for each of the scheduling algorithms in part a? C. What is the waiting time of each process for each of the scheduling algorithms in part a? D. Which of the schedules in part A results in the minimal average waiting time (over all processes)?
FCFS: p1,p2,p3,p4,p5 SJF:P2,P4,P3,P5,P1 Non pree Priority: p2,p5,p3,p1,p4 RR(Q=1): p1,p2,p3,p4,p5,,p1,p3,p5,p1,p5,p1,p5,p1,p5,p1,p1,p1,p1,p1 B: The turn around time is the time it takes for each process to be done. C: The time spent waiting on other processes before it gets to yours. D: SJF has the lowest average waiting time
4.2 Describe the differences among short-term, medium-term, and long-term scheduling.
Longterm: decides which JOBS are loaded into memory Medium term: selects processes that are in ready queue and removes them from memory then reinstates them later Short Term: picks processes from ready queue and sends them to CPU
2.2 How does the distinction between monitor mode and user mode function as a rudimentary form of protection (security) system?
Monitor mode can do everything on an OS. User mode is limited to certain instructions only. Monitor mode helps protect users from doing malicious things to the system.
3.11 What is the main advantage of the layered approach to system design?
More systems/layers to go through in order to break so its more secure. Easier to debug layer by layer
1.6 Define the essential properties of the following types of operating systems: F. Distributed
Multiple CPU'S, Local memory is used
6.2 Define the difference between preemptive and nonpreemptive schduling. State why strict nonpreemptive scheduling is unlikely to be used in a computer center.
Non preemptive processes can run until completion. if the job never completes this will starve the other processes. Preemptive scheduling gives a processes a limit of how long they run.
3.1 What are the five major activities of an operating system in regard to process management?
Process sync, Process creation and deletion, process communication, process suspension and resumption process deadlock
6.6 What advantage is there in having different time-quantum sizes on different levels of a multilevel queueing system?
Processes which need more require more servicing like interactive process can be in the Queue for a shorter time. Processes which require more time can be in the Queue with fewer context switches in between. If a job is larger we can give it more time.
3.6 List five services provided by an operating system. Explain how each provides convenience to the users. Explain also in which cases it would be impossible for user-level programs to provide these services.
Program execution File management FIle I/O Error detection Process communication
1.7 We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to "waste" resources? Why is such a system not really wasteful?
The usage of GUI's (graphical user interface) is necessary in a user facing system for average users although it takes up more computing power it is not a waste because of the ease of use it delivers.
2.1 Compare the prefetching scheme with the spooling scheme, where the CPU overlaps the input of one job with the computation and output of other jobs.
Spooling(pipe lining) is more efficient. The user does/implements prefetching the OS does spooling
1.9 Describe the differences between symmetric and asymmetric multiprocessing. What are three advantages and one disadvantage of multiprocessor systems?
Symmetric: all systems are equal. All can process I/O Asymmetric: follows idea of slaves and master. All systems are not equal. Only master processes I/O Advantages: more fault tolerant, execute programs more quickly, more reliable, save money by sharing resources. Disadvantages: more complex in design
1.6 Define the essential properties of the following types of operating systems: D. Real time
System must respond within a deadline
1.10 What is the main difficulty that a programmer must overcome in writing an operating system for a real-time environment?
The deadline. Hard Deadlines: The dead line must always be met. Soft Deadlines: can be missed sometimes.
6.1 A CPU scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many possible different schedules are there? Give a formula in terms of n.
There are n! ways to schedule n processes.
1.8 Under what circumstances would a user be better off using a time-sharing system, rather than a personal computer or single-user workstation?
When you are the only one using such system.
3.7 What is the purpose of system calls?
To get a service from the OS
3.5 What is the purpose of the command interpreter? Why is it usually separate from the kernel?
To interpret commands from the user. It is separate so it can be updated and changed easily
2.3 What are the differences between a trap and an interrupt? What is the use of each function?
Trap is generated by software written by users letting OS know of an event. Interrupt is OS generated and can occur because of a trap among other reasons.
1.6 Define the essential properties of the following types of operating systems: B. Interactive
User input is given then machine responds ( user and machine interact a lot)
What are the 2 types of threads and how do they affect the kernel in terms of scheduling?
User level thread: Kernel is not aware so Kernel cannot schedule because there is a user layer sitting on top of the kernel layer. Kernel level thread: kernel can schedule threads because it is aware.