Operating Systems Midterm Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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.

((P1's waiting time + P1's brust time) + (P2's waiting time + P2's brust time) + (P3's waiting time + P3's brust time)) / 3 a. ((0 + 8) + (7.6 + 4) + (11+ 1) ) / 3 = 10.5333 b. ((0 + 8) + (8.6 + 4) + (7+ 1) ) / 3 = 9.5333 c. ((6 + 8) + (1.6 + 4) + (0+ 1) ) / 3 = 6.866 Remember that turnaround time is completion time minus arrival time, so you have to subtract the arrival times to compute the turnaround. FCFS is 11 if you forget to subtract arrival time

Define the difference between preemptive and nonpreemptive schduling. State why strict nonpreemptive scheduling is unlikely to be used in a computer center.

(1) Preemptive scheduling allows a process to be interrupted in the midst of its execution, taking the CPU away and allocating it to another process. Nonpreemptive scheduling ensures that a process relinquishes control of the CPU only when it finishes with its current CPU burst. (2) If nonpreemptive scheduling is used in a computer center, a process is capable of keeping other processes waiting for a long time.

Describe the actions a kernel takes to context switch between processes.

(1) suspending the progression of one process and storing the CPU's state (i.e., the context) for that process somewhere in memory, (2) retrieving the context of the next process from memory and restoring it in the CPU's registers and (3) returning to the location indicated by the program counter (i.e., returning to the line of code at which the process was interrupted) in order to resume the process.

MS-DOS provided no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system.

(a) A method of time sharing must be implemented to allow each of several processes to have access to the system. This method involves the preemption of processes that do not voluntarily give up the CPU (by using a system call, for instance) and the kernel being reentrant(so more than one process may be executing kernel code concurrently.) (b) Processes and system resources must have protections and must be protected from each other. Any given process must be limited in the amount of memory it can use and the operations it can perform on devices like disks. (c) Care must be taken in the kernel to prevent deadlocks between processes, so processes aren't waiting for each other's allocated resources.

Answer the following questions using the banker's algorithm: A. What is the content of the matrix Need? B. Is the system in a safe state? C. If a request from process P1 arrives for (0, 4, 2, 0), can the request be granted immediately?

(a) P0 :0000,P1 :0750,P2 :1002,P3 :0020,P4 :0642 (b) Yes. With Available being equal to (1,5, 2, 0), either process P0 or P3 could run. Once process P3 runs, it releases its resources, which allow all other existing processes to run. (c) Yes, it can. This results in the value of Available being (1, 1, 0, 0). One ordering of processes that can finish is P0, P2, P3, P1, and P4.

Describe the differences among short-term, medium-term, and long-term scheduling.

(a) Short-term (CPU scheduler) - selects from among the processes that are ready to execute and allocates CPU to them. (b) Medium-term - used especially with time-sharing systems as an intermediate scheduling level. A swapping scheme is implemented to remove partially run programs from memory and reinstate them later to continue where they left off. (c) Long-term (job scheduler) - determines which jobs are brought into memory for processing. The primary difference is in the frequency of their execution. The short-term must select a new process quite often. Long-term is used much less often since it handles placing jobs in the system and may wait for a job to finish before it admits another one.

What are the main advantages of the microkernel approach to system design?

(a) adding a new service does not require modifying the kernel, (b) it is more secure as more operations are done in user mode than in kernel mode, and (c) a simpler kernel design and functionality typically results in a more reliable operating system.

Consider a system consisting of m resources of the same type, being shared by n processes. Resources can be requested and released by processes only one at a time. Show that the system is deadlock free if the following two conditions hold: A. The maximum need of each process is between 1 and m resources B. The sum of all maximum needs is less than m+n.

...Proof: Suppose N = Sum of all Need(i), A = Sum of all Allocation(i), M = Sum of all Max(i). Use contradiction to prove. Assume this system is not deadlock free. If there exists a deadlock state, then A = m because there's only one kind of resource and resources can be requested and released only one at a time. From condition b, N + A = M < m + n. So we get N + m < m + n. So we get N < n. It shows that at least one process i that Need(i) = 0. From condition a, Pi can release at least 1 resource. So there are n-1 processes sharing m resources now, condition a and b still hold. Go on the argument, no process will wait permenently, so there's no deadlock.

What are the 3 main purposes of an operating system ?

1. Use computer hardware in an efficient manner 2. Execute user programs and make solving user problems easier 3. Make the computer system convenient to use

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 are useful because they can increase the speed of the average memory access, and they do so without taking up as much physical space as the lower elements of the memory hierarchy. They ameliorate the (performance critical) memory access time by leveraging spatial and temporal locality. Unfortunately, caches also introduce an additional level of complexity (coherency and consistency assurance). We also incur an economic and space (at the computer organization level) penalty when we add a cache. Making a cache as large as a disk would be ineffective because it would be too costly, the immense size would slow it down, and a cache is generally a volatile memory, while we want data on disks to be persistent.

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 the CPU to be involved in the transfer, allowing the transfer to complete more quickly and the CPU to perform other tasks concurrently.

What are the essential properties of a Distributed Operating System ?

Divides computation up among several computers. The computers do not share memory or a clock; they communicate with each other over communication lines (e.g. high-speed bus, telephone line)

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.

Dual-mode bit: Allows hardware-level distinction between user and system modes and hence protects the OS from malicious or faulty user programs by restricting dangerous behavior to system mode operation. - Memory protection (base and limit registers): Base and limit registers effectively define the legal address range of a program and as such, they allow the CPU to check that every address a program generates is legal, protecting memory from malicious or unwanted accesses. - Fixed-rate clock and counter for interrupts: A clock and counter can be used to implement regular interrupts (and context switches to the OS) through which we can avoid the possibility of getting stuck in an infinite user-space loop.

What is the purpose of the command interpreter? Why is it usually separate from the kernel?

It reads commands from the user or from a file of commands and executes them, usually by turning them into one or more system calls. It is usually not part of the kernel since the command interpreter is subject to changes.

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?

It will favour the I/O-bound programs because of the relatively short CPU burst request by them; however, the CPU-bound programs will not starve because the I/O-bound programs will relinquish the CPU relatively often to do their I/O.

What are the essential properties of a Batch Operating System ?

Jobs with similar needs are batched together and run through the computer as a group, by an operator or automatic job sequencer.

What is the main advantage of Multiprogramming ?

Makes use of the CPU by overlapping the demands for the CPU and its I/O devices from various users. It attempts to increase CPU utilization by always having something for the CPU to execute.

Explain the four necessary conditions for a deadlock.

Mutual exclusion, Hold and wait, No preemption, Circular wait.

Is it possible to have a deadlock involving only one single process? Explain your answer.

No. There is no dead-lock because there is only one process and hence no condition about Mutual Exclusion.

What are the essential properties of an Interactive Operating System ?

On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next "control statement" from the user's keyboard.

Prefetching is a method of overlapping the I/O of a job with that job's own computation. The idea is simple. After a read operation completes and the job is about to start operating on the data, the input device is instructed to begin the next read immediately. The CPU and input device are then both busy. With luck, by the time the job is ready for the next data item, the input device will have finished reading that data item. The CPU can then begin processing the newly read data, while the input device stats to read the following data. A similar idea can be used for output. In this case, the job creates data that are put into a buffer until an output device can accept them. 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.

Prefetching is a user-based activity, while spooling is a system-based activity. Spooling is a much more effective way of overlapping I/O and CPU operations. The central idea of both prefetching and spooling is to try to keep both CPU and I/O busy, so as to improve the performance of the system. When doing prefetching, the instructions may need to be rearranged, so that to start read as early as possible, and probably to postpone some write until the output device can accept them. Spooling is often used in batch processing, there are many tasks ready to be run in the system, so the system has more freedom to schedule them to improve the performance.

Can we ensure the same degree of security in a time-shared machine as we have in a dedicated machine? Explain your answer.

Probably not since any protection scheme devised by humans can inevitably be broken by a human, and the more complex the scheme, the more difficult it is to feel confident of its correct of its correct implementation.

What advantage is there in having different time-quantum sizes on different levels of a multilevel queueing system?

Processes which need more frequent servicing, such as interactive processes, can be in a queue with a small q. Processes that are computationally intensive can be in a queue with a larger quantum, requiring fewer context switches to complete the processing, making more efficient use of the CPU.

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?

Single-user systems should maximize use of the system for the users. A GUI might "waste" CPU cycles, but it optimizes the user's interaction with the system. For example, when we use PC's or handheld computers, it's appropriate for the operating system to forsake this principle and to "waste" resources. Because those O.S.'s are designed for individual usability , for ease of use, with some attention paid to performance, and none paid to resource utilization.

Consider the following preemptive priority-scheduling algorithm based on dynamically changing priorities. Larger priority numbers imply higher priority. When a process is waiting for the CPU (in the ready queue but not running), its priority changes at a rate α; when it is running, its priority changes at a rate β. All processes are given a priority of 0 when they enter the ready queue. The parameters α and β can be set to give many different scheduling algorithms. A. What is the algorithm that results from β > α > 0? B. What is the algorithm that results from α < β < 0?

Solution (a) What is the algorithm that results from β > α > 0? Since β is a rate and it is greater than that of α, processes that are running will con- tinually receive a much higher priority. At the same time, the priority of processes waiting to be run will increase, however, this increase will not be as fast as the pro- cess running on the CPU. This will result in a first-come first-serve (FCFS) type of situation where when no process is running the one that has been waiting the longest will be ran, and its priority will continuously increase faster than the others until it stops. Solution (b) What is the algorithm that results from α < β < 0? New processes in this scheme will always be ran immediately, and older processes will sit in the ready queue until the most recent process finishes. This is essentially Last In First Out.

In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems. What are two such problems?

Stealing or copying one's program or data; using system resources (CPU, memory, disk space, peripherals) without proper accounting.

Describe the differences between symmetric and asymmetric multiprocessing.

Symmetric Processing treats all processors as equals; I/O can be processed on any of them. Asymmetric Processing designates 1 CPU as the master, which is the only one capable of performing I/O; the master distributes computational work among the other CPUs.

The experimental Synthesis operating system has an assembler incorporated within the kernel. To optimize system-call performance, the kernel assembles routines within kernel space to minimize the path that the system call must take through the kernel. This approach is the antithesis of the layered approach, in which the path through the kernel is extended so that building the operating system is made easier. Discuss the pros and cons of the Synthesis approach to kernel design and to system performance optimization.

Synthesis is impressive due to the performance it achieves through on-the-fly compilation. Unfortunately, it is difficult to debug problems within the kernel due to the fluidity of the code. Also, such compilation is system specific, making Synthesis difficult to port (a new compiler must be written for each architecture).

What is the purpose of system calls?

System calls allow user-level processes to request services of the operating system.

What is the purpose of system programs?

System programs can be thought of as bundles of useful system calls. They provide basic functionality to users so that users do not need to write their own programs to solve common problems.

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?

The CPU current-register-set pointer is changed to point to the set containing the new context, which takes very little time. If the context is in memory, one of the contexts in a register set must be chosen and moved to memory, and the new context must be loaded from memory into the set. This process takes a little more time than on systems with one set of registers, depending on how a replacement victim is selected.

How does the distinction between monitor mode and user mode function as a rudimentary form of protection (security) system?

The Operating system must ensure correct operating of the computer system. Hardware has two modes to prevent user programs from interfering with the proper operation of the system, which are user mode and monitor mode. Various instructions are privileged, and can be executed in only monitor mode.

What are the five major activities of an operating system in regard to file management?

The creation and deletion of files • The creation and deletion of directories • The support of primitives for manipulating files and directories • The mapping of files onto secondary storage • The backup of files on stable (nonvolatile) storage media

What is the main advantage for an operating-system designer of using a virtual-machine architecture? What is the main advantage for a user?

The fundamental goal of a virtual machine architecture is to share the same hardware yet run several different execution environments. Accordingly, from the perspective of an operating system designer, a virtual machine architecture enables a complete protection of the various system resources as each virtual machine is completely isolated from all other virtual machines. From the perspective of a user, a virtual machine architecture enables the concurrent execution of multiple execution environments on a single machine.

What is the main difficulty that a programmer must overcome in writing an operating system for a real-time environment?

The main difficulty is keeping the O.S within the fixed time constraints of a real-time system. If the system does not complete a task in a certain time frame, it may cause a breakdown of the entire system it is running, therefore a programmer must be sure the scheduling schemes don't allow response time to exceed the time constraint.

What is the essential property of Real-Time Operating System ?

The system must respond to inputs/commands within a fixed amount of time(deadline) to ensure correct performance.

What are the essential properties of Time-Sharing Operating System ?

Uses CPU scheduling and multiprogramming to provide economical interactive use of a system. The CPU switches rapidly from one user to another.

Consider a system consisting of four resources of the same type that are shared by three processes, each of which needs at most two resources. Show that the system is deadlock-free.

Yes, this system is deadlock-free. Proof by contradiction. Suppose the system is deadlocked. This implies that each process is holding one resource and is waiting for one more. Since there are three processes and four resources, one process must be able to obtain two resources. This process requires no more resources and, therefore it will return its resources when done.

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. FCFS—discriminates against short jobs since any short jobs arriving after long jobs will have a longer waiting time. b. RR—treats all jobs equally (giving them equal bursts of CPU time) so short jobs will be able to leave the system faster since they will finish first. c. Multilevel feedback queues—work similar to the RR algorithm— they discriminate favorably toward short jobs.

What are the three major activities of an operating system in regard to memory management?

a. Keep track of which parts of memory are currently being used and by whom. b. Decide which processes are to be loaded into memory when memory space becomes available. c. Allocate and de-allocate memory space as needed.

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.

a. Program execution. The operating system loads the contents (or sections) of a file into memory and begins its execution. A user level program could not be trusted to properly allocate CPU time. b. I/O operations. Disks, tapes, serial lines, and other devices must be communicated with at a very low level. The user need only specify the device and the operation to perform on it, while the system converts that request into device- or controller-specific commands. User-level programs cannot be trusted to access only devices they should have access to and to access them only when they are otherwise unused. c. File-systemmanipulation. There aremany details in file creation, deletion, allocation, and naming that users should not have to perform. Blocks of disk space are used by files and must be tracked. Deleting a file requires removing the name file information and freeing the allocated blocks. Protections must also be checked to assure proper file access. User programs could neither ensure adherence to protection methods nor be trusted to allocate only free blocks and deallocate blocks on file deletion. d. Communications. Message passing between systems requires messages to be turned into packets of information, sent to the network controller, transmitted across a communications medium, and reassembled by the destination system. Packet ordering and data correction must take place. Again, user programs might not coordinate access to the network device, or they might receive packets destined for other processes. e. Error detection. Error detection occurs at both the hardware and software levels. At the hardware level, all data transfers must be inspected to ensure that data have not been corrupted in transit. All data on media must be checked to be sure they have not changed since they were written to the media. At the software level, media must be checked for data consistency; for instance, whether the number of allocated and unallocated blocks of storage match the total number on the device. There, errors are frequently process-independent (for instance, the corruption of data on a disk), so there must be a global program (the operating system) that handles all types of errors. Also, by having errors processed by the operating system, processes need not contain code to catch and correct all the errors possible on a system.

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.

What are the five major activities of an operating system in regard to process management?

a. The creation and deletion of both user and system processes b. The suspension and resumption of processes c. The provision of mechanisms for process synchronization d. The provision of mechanisms for process communication e. The provision of mechanisms for deadlock handling

Many CPU scheduling algorithms are parameterized. For example, the RR algorithm requires a parameter to indicate the time slice. Multilevel feedback queues require parameters to define the number of queues, the scheduling algorithms for each queue, the criteria used to move processes between queues, and so on. These algorithms are thus really sets of algorithms (for example, the set of RR algorithms for all time slices, and so on). One set of algorithms may include another (for example, the FCFS algorithm is the RR algorithm with an infinite time quantum). What (if any) relation holds between the following pairs of sets of algorithms? A. Priority and SJF B. Multilevel feedback queues and FCFS C. Priority and FCFS D. RR and SJF

a. The shortest job has the highest priority. b. The lowest level of MLFQ is FCFS. c. FCFS gives the highest priority to the job having been in existence the longest. d. None.

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)?

b & c see images d. SJF (either nonpreemptive algorithm or preemptive algorithm, since they given the same result in this case) has the minimum average waiting time.

Protecting the operating system is crucial to ensuring that the computer system operates correctly. Provision of this protection is the reason behind dual-mode operation, memory protection, and the timer. To allow maximum flexibility, however, we would also like to place minimal constraints on the user.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) - Otherwise process can get into monitor/kernel mode. c) - Otherwise any process can read private data (security risk). d) - Otherwise any process can change monitor data. g) - Otherwise any process can run forever.

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.

n! (n factorial = n × (n - 1) × ( n - 2) × ... × 2 × 1).

What are the three major activities of an operating system in regard to secondary-storage management?

• Free-space management. • Storage allocation. • Disk scheduling.

List three examples of deadlocks that are not related to a computer-system environment.

• Two cars crossing a single-lane bridge from opposite directions. • A person going down a ladder while another person is climbing up the ladder. • Two trains traveling toward each other on the same track.

What are the essential properties of a Network Operating System ?

A group of two or more computer systems are linked together. Provides file sharing, communication scheme and runs independently from other computers on the network.

What are the differences between a trap and an interrupt? What is the use of each function?

A trap is a software-generated interrupt caused either by an error, or by a specific request from a user program that an operating-system service by performed. An interrupt is a signal that gets the attention of the CPU and is usually generated when I/O is required. When a trap occurs, the hardware transfers control to the operating system.

Under what circumstances would a user be better off using a time-sharing system, rather than a personal computer or single-user workstation?

A user is better off under 3 situations, when it's cheaper, faster or easier. For example; 1. When a user is paying for management, and the costs are cheaper for a time sharing system than for a single-user computer. 2. When running a simulation or calculation that takes a long time to run on a single PC or workstation. 3. When a user is traveling and doesn't have a laptop to carry around, they can connect remotely to a time-shared system and do their work.

Consider the following resource-allocation policy. Requests and releases for resources are allowed at any time. If a request for resources cannot be satisfied because the resources are not available, then we check any processes that are blocked, waiting for resources. If they have the desired resources, then these resources are taken away from them and are given to the requesting process. The vector of resources for which the process is waiting is increased to include the resources that were taken away. For example, consider a system with three resource types and the vector Available initialized to (4,2,2). If process P0 asks for (2,2,1), it gets them. If P1 asks for (1,0,1), it gets them. Then, if P0 asks for (0,0,1), it is blocked (resource not available). If P2 now asks for (2,0,0), it gets the available one (1,0,0) and one that was allocated to P0 (since P0 is blocked). P0's Allocation vector goes down to (1,2,1), and its Need vector goes up to (1,0,1). A. Can deadlock occur? If you answer "yes", give an example. If you answer "no", specify which necessary condition cannot occur. B. Can indefinite blocking occur? Explain your answer.

A. Deadlock cannot occur because preemption exists. B. Yes. A process may never acquire all the resources it needs if they are continuously preempted by a series of requests.

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.Priority process will get more precedence because two pointers can access priority process more often. B.Higher priority process will get more time to process. Otherwise, lower priority process will get less time to process. C.Spend more time on higher priority process.

What are three advantages and one disadvantage of multiprocessor systems?

Advantages; Can save money, by sharing power supplies, housings, and peripherals. Can execute programs more quickly and have increased reliability. Disadvantages; Multiprocessor systems are more complex in both hardware & software.

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.

An operating system for a machine of this type would need to remain in control(or monitor mode) at all times. This could be accomplished by two methods: (a) Software interpretation of all user programs (like some BASIC, APL, and LISP systems, for example). The software interpreter would provide, in software, what the hardware does not provide. (b) Require meant that all programs be written in high-level languages so that all object code is compiler-produced. The compiler would generate (either in-line or by function calls) the protection checks that the hardware is missing.

What is the main advantage of the layered approach to system design?

As in all cases of modular design, designing an operating system in a modular way has several advantages. The system is easier to debug and modify because changes affect only limited sections of the system rather than touching all sections of the operating system. Information is kept only where it is needed and is accessible only within a defined and restricted area, so any bugs affecting that data must be limited to a specific module or layer.


Set pelajaran terkait

The Adventure of the Speckled Band

View Set

Recognizing Race and Ethnicity Fitzgerald Ch.3

View Set

Residential Sales Comparison and Income Approaches

View Set

Chapter 15: Collective Bargaining and Labor Relations

View Set