Operating systems are an essential part of any computer system. Similarly, . As we wrote this seventh edition of Operating System Concepts, we were guided. To mu!/ children, Lemor, Sioan, and Aaron. Atpi Silbgrschaf2. To nt/ toife, Carla, and mi!/ childrem, Gatien Otoen and Maddie. Peter Bder Gult)in. In meli10r!/. volwarmdilanmi.gq - Ebook download as PDF File .pdf) or read book online. A Book on C Programming in C (4th Edition ).
|Language:||English, French, German|
|ePub File Size:||27.79 MB|
|PDF File Size:||19.55 MB|
|Distribution:||Free* [*Sign up for free]|
Operating systems are an essential part of any computer system. Similarly, . As we wrote this Ninth Edition of Operating System Concepts, we were guided. Welcome to the Web site for Operating System Concepts, Seventh Edition by Abraham Silberschatz, Peter Baer Galvin and Greg Gagne. This Web site gives you. Operating System Concepts, Seventh Edition [Abraham Silberschatz, Peter B. Galvin, Another defining moment in the evolution of operating systems Small footprint of prior editions or perhaps if you are lucky, someone has a PDF of them.
Unlike static PDF Operating System Concepts 7th Edition solution manuals or printed answer keys, our experts show you how to solve each problem step-by-step. No need to wait for office hours or assignments to be graded to find out where you took a wrong turn. You can check your reasoning as you tackle a problem using our interactive solutions viewer. Plus, we regularly update and improve textbook solutions based on student ratings and feedback, so you can be sure you're getting the latest information available.
How is Chegg Study better than a printed Operating System Concepts 7th Edition student solution manual from the bookstore?
Our interactive player makes it easy to find solutions to Operating System Concepts 7th Edition problems you're working on - just go to the chapter for your book. Hit a particularly tricky question? Bookmark it to easily review again before an exam. The best part? As a Chegg Study subscriber, you can view available interactive solutions manuals for each of your classes for one low monthly price. The virtual memory subsystem and the storage subsystem are typically tightly-coupled and requires careful design in a layered system due to the following interactions.
Many systems allow files to be mapped into the virtual memory space of an executing process. On the other hand, the virtual memory subsystem typically uses the storage system to provide the backing store for pages that do not currently re- side in memory.
Also, updates to the filesystem are sometimes buffered in physical memory before it is flushed to disk, thereby requiring care- ful coordination of the usage of memory between the virtual memory subsystem and the filesystem. How do user programs and system services interact in a microker- nel architecture?
What are the disadvantages of using the microkernel approach? Benefits typically include the following 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 reli- able operating system.
These messages are conveyed by the operating system. In what ways does it differ from the layered approach? The modular kernel approach requires subsystems to interact with each other through carefully constructed interfaces that are typi- cally narrow in terms of the functionality that is exposed to external modules.
The layered kernel approach is similar in that respect. How- ever, the layered kernel imposes a strict ordering of subsystems such that subsystems at the lower layers are not allowed to invoke opera- tions corresponding to the upper-layer subsystems.
There are no such restrictions in the modular-kernel approach, wherein modules are free to invoke each other without any constraints. What is the main advantage for a user?
The system is easy to debug, and security problems are easy to solve. Virtual machines also provide a good platform for operating system research since many different operating systems may run on one physical system. Java is an interpreted language. This means that the JVM inter- prets the bytecode instructions one at a time. Typically, most interpreted environments are slower than running native binaries, for the interpre- tation process requires converting each instruction into native machine code.
A just-in-time JIT compiler compiles the bytecode for a method into native machine code the first time the method is encountered. This means that the Java program is essentially running as a native appli- cation of course, the conversion process of the JIT takes time as well but not as much as bytecode interpretation. Furthermore, the JIT caches compiled code so that it may be reused the next time the method is en- countered.
A Java program that is run by a JIT rather than a traditional interpreter typically runs much faster. What factors need to be considered in choosing the host operating system? A guest operating system provides its services by mapping them onto the functionality provided by the host operating system. A key issue that needs to be considered in choosing the host operating system is whether it is sufficiently general in terms of its system-call interface in order to be able to support the functionality associated with the guest operating system.
To optimize system-call performance, the kernel assembles routines within kernel space to minimize the path that the sys- tem call must take through the kernel. This approach is the antithesis of the layered approach, in which the path through the kernel is extended to make building the operating system 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.
This program works by first prompting the user for the name of the source and destination files. Be sure to include all necessary error checking, including ensuring that the source file exists. Once you have correctly designed and tested the program, if you used a system that supports it, run the program using a utility that traces system calls. Linux systems provide the ptrace utility, and Solaris systems use the truss or dtrace command.
On Mac OS X, the ktrace facility provides similar functionality. Please refer to the supporting Web site for solution. A process is is a program in execution and is the unit of work in a modern time-sharing system. Such a system consists of a collection of processes: Operating-system processes executing system code and user processes executing user code. By switching the CPU between processes, the oper- ating system can make the computer more productive. We also introduce the notion of a thread lightweight process and interprocess communication IPC.
Threads are discussed in more detail in Chapter 4. Exercises 3. A swapping scheme is implemented to remove partially run programs from memory and reinstate them later to continue where they left off. 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 a while for a job to finish before it admits another one.
In general, the operating system must save the state of the currently running process and restore the state of the process sched- uled to be run next. Saving the state of a process typically includes the values of all the CPU registers in addition to memory allocation. Con- text switches must also perform many architecture-specific operations, including flushing data and instruction caches. Describe the undesirable circumstances that could arise from not enforcing either the "at most once" or "exactly once" semantics.
Describe possible uses for a mechanism that had neither of these guarantees. Consider if a remote procedure were withdrawing money from a bank account on a system that did not support these semantics. It is possible that a single invocation of the remote procedure might lead to multiple withdrawals on the server. For a system to support either of these semantics generally requires the server maintain some form of client state such as the timestamp described in the text.
If a system were unable to support either of these sematics, then such a system could only safely provide remote procedures that do not alter data or provide time-sensitive results. However, an inquiry into an account balance or other accunt information such as name, address, etc. Please refer to the supporting Web site for source code solution. Symmetric and asymmetric communication b.
Automatic and explicit buffering c. Send by copy and send by reference d. Fixed-sized and variable-sized messages Answer: Symmetric and asymmetric communication - A benefit of sym- metric communication is that it allows a rendezvous between the sender and receiver.
As a result, message-passing systems often provide both forms of synchronization. Automatic and explicit buffering - Automatic buffering provides a queue with indefinite length; thus ensuring the sender will never have to block while waiting to copy a message. There are no spec- ifications how automatic buffering will be provided; one scheme may reserve sufficiently large memory where much of the mem- ory is wasted.
Explicit buffering specifies how large the buffer is. In this situation, the sender may be blocked while waiting for available space in the queue. However, it is less likely memory will be wasted with explicit buffering. Send by copy and send by reference - Send by copy does not allow the receiver to alter the state of the parameter; send by ref- erence does allow it. A benefit of send by reference is that it allows the programmer to write a distributed version of a centralized ap- plication.
Fixed-sized and variable-sized messages - The implications of this are mostly related to buffering issues; with fixed-size mes- sages, a buffer with a specific size can hold a known number of messages. The number of variable-sized messages that can be held by such a buffer is unknown. Consider how Windows handles this situation: Larger mes- sages i.
For- mally, it can be expressed as: The number of the sequence will be provided in the command line. For example, if 5 is provided, the first five numbers in the Fibonacci sequence will be output by the child process. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the sequence.
Have the parent invoke the wait call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a non-negative number is passed on the command line. It is this separate program that will run as a child process outputting the Fibonacci sequence. Per- form necessary error checking to ensure that a non-negative number is passed on the command line.
Operating System Concepts
Allow the fortunes to contain multiple lines. The date client shown in Figure 3. For example, if a client sends the server the string Hello there! This server will wait for a client connection using the accept method. When a client connection is received, the server will loop, performing the following steps: The server will break out of the loop only when it has determined that the client has closed the connection.
The date server shown in Figure 3. BufferedReader class. BufferedReader extends the java. Reader class, which is used for reading character streams. However, the echo server cannot guarantee that it will read characters from clients; it may receive binary data as well.
The class java. InputStream deals with data at the byte level rather than the character level. Thus, this echo server must use an object that extends java. The read method in the java. Another approach to designing this program is to establish a shared-memory segment between the parent and child processes. This technique allows the child to write the contents of the Fibonacci sequence to the shared- memory segment and has the parent output the sequence when the child completes.
Because the memory is shared, any changes the child makes to the shared memory will be reflected in the parent process as well. The program first requires creating the data structure for the shared-memory segment. This is most easily accom- plished using a struct.
This data structure will contain two items: These items can be represented in a struct as follows: Create a shared-memory segment of size shared data. Attach the shared-memory segment to its address space. Set the value of sequence size to the parameter on the command line.
Fork the child process and invoke the wait system call to wait for the child to finish. Output the value of the Fibonacci sequence in the shared-memory segment.
Detach and remove the shared-memory segment. The child process will then write the Fibonacci sequence to shared memory and finally will detach the segment.
One issue of concern with cooperating processes involves synchro- nization issues. In this exercise, the parent and child processes must be synchronized so that the parent does not output the Fibonacci sequence until the child finishes generating the sequence. These two processes will be synchronized using the wait system call; the parent process will invoke wait , which will cause it to be suspended until the child process exits.
This com- mand lists the status of various POSIX interprocess communication mech- anisms, including shared-memory segments. Some of the fields of this structure include: Permissions are identified according to the following: Mode Meaning Read permission of owner.
Shared-memory segments can be identified according to a user-specified key or according to the integer value returned from the shmget system call, which represents the integer identifier of the shared-memory seg- ment created. The shm ds structure for a given integer segment identifier can be obtained with the following shmctl system call: Write a C program that is passed an identifier for a shared-memory segment.
This program will invoke the shmctl function to obtain its shm ds structure. It will then output the following values of the given shared-memory segment: Many modern operating systems now provide features for a process to contain multiple threads of control.
This chapter introduces many concepts associated with multithreaded computer systems and covers how to use Java to create and manipulate threads. We have found it especially useful to discuss how a Java thread maps to the thread model of the host operating system. Exercises 4. An example of this is a program that calculates an in- dividual tax return.
Such a program must closely monitor its own working space such as open files, environment variables, and current working directory. Context switching between user threads is quite similar to switching between kernel threads, although it is dependent on the threads library and how it maps user threads to kernel threads.
In general, context switching between user threads involves taking a user thread of its LWP and replacing it with another thread. This act typically involves saving and restoring the state of the registers. When a kernel thread suffers a page fault, another kernel thread can be switched in to use the interleaving time in a useful manner. A single-threaded process, on the other hand, will not be capable of performing useful work when a page fault takes place.
Therefore, in scenarios where a program might suffer from frequent page faults or has to wait for other system events, a multi-threaded solution would perform better even on a single-processor system. Register values b. Heap memory c. Global variables d. Stack memory Answer: The threads of a multithreaded process share heap memory and global variables. Each thread has its separate set of register values and a separate stack. A multithreaded system comprising of multiple user-level threads cannot make use of the different processors in a multiprocessor system simultaneously.
The operating system sees only a single process and will not schedule the different threads of the process on separate processors. Consequently, there is no performance benefit associated with executing multiple user-level threads on a multiprocessor system.
Instead, Linux treats both in the same way, allowing a task to be more akin to a process or a thread depending on the set of flags passed to the clone system call. However, many operating sys- tems—such as Windows XP and Solaris—treat processes and threads differently. Typically, such systems use a notation wherein the data struc- ture for a process contains pointers to the separate threads belonging to the process.
Contrast these two approaches for modeling processes and threads within the kernel. On one hand, in systems where processes and threads are considered as similar entities, some of the operating system code could be simplified. A scheduler, for instance, can consider the different pro- cesses and threads in equal footing without requiring special code to examine the threads associated with a process during every scheduling step.
On the other hand, this uniformity could make it harder to impose process-wide resource constraints in a direct manner. Instead, some ex- tra complexity is required to identify which threads correspond to which process and perform the relevant accounting tasks. Exercises 25 Answer: Let the number of user-level threads in the program be more than the number of processors in the system.
Discuss the performance implications of the following scenarios. The number of kernel threads allocated to the program is less than the number of processors.
The number of kernel threads allocated to the program is equal to the number of processors. The number of kernel threads allocated to the program is greater than the number of processors but less than the number of user- level threads. When the number of kernel threads is less than the number of processors, then some of the processors would remain idle since the scheduler maps only kernel threads to processors and not user-level threads to processors.
When the number of kernel threads is exactly equal to the number of processors, then it is possible that all of the processors might be utilized simultaneously. However, when a kernel- thread blocks inside the kernel due to a page fault or while invoking system calls , the corresponding processor would remain idle. When there are more kernel threads than processors, a blocked kernel thread could be swapped out in favor of another kernel thread that is ready to execute, thereby increasing the utilization of the multiprocessor system.
This program should work as follows: The user will run the program and will enter a number on the command line. The program will then create a separate thread that outputs all the prime numbers less than or equal to the number entered by the user. The user will enter on the command line the number of Fibonacci numbers that the program is to generate. When the thread finishes execution, the parent thread will output the sequence generated by the child thread. Because the parent thread cannot begin outputting the Fi- bonacci sequence until the child thread finishes, this will require having the parent thread wait for the child thread to finish using the techniques described in Section 4.
Please refer to the supporting Web site for source code solu- tion. However, this server is single-threaded meaning the server cannot respond to concurrent echo clients until the current client exits. Modify the solution to Exercise 3. By switch- ing the CPU among processes, the operating system can make the computer more productive.
In this chapter, we introduce the basic scheduling concepts and discuss in great length CPU scheduling. This is their first exposure to the idea of resource allocation and scheduling, so it is important that they understand how it is done. Gantt charts, simulations, and play acting are valuable ways to get the ideas across. Show how the ideas are used in other situations like waiting in line at a post office, a waiter time sharing between customers, even classes being an interleaved Round-Robin scheduling of professors.
A simple project is to write several different CPU schedulers and compare their performance by simulation. The instructor can make the trace tape up in advance to provide the same data for all students. The first line of a job was the word JOB and the job number. The job was terminated by an END line with the job number again. Round-Robin is more difficult, since it requires putting unfinished requests back in the ready queue.
Exercises 5. Such programs typically do not use up their entire CPU quantum. CPU utilization and response time b. Average turnaround time and maximum waiting time c. 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.
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.
Operating System Concepts (7th Edition)
CPU utilization is maximized by running long-running CPU-bound tasks without performing context switches. What are the implications of assigning the following values to the parameters used by the algorithm? Consequently, the scheduling algorithm is almost memory-less, and simply predicts the length of the previous burst for the next quantum of CPU execution.
What is the turnaround time of each process for each of the scheduling algorithms in part a? What is the waiting time of each process for each of the scheduling algorithms in part a? Which of the schedules in part a results in the minimal average waiting time over all processes? The four Gantt charts are b.
Shortest Job First 5. First-come, first-served b. Shortest job first c. Priority Answer: Shortest job first and priority-based scheduling algorithms could result in starvation.
What would be the effect of putting two pointers to the same process in the ready queue? What would be the major advantages and disadvantages of this scheme? How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers? In effect, that process will have increased its priority since by getting time more often it is receiving preferential treatment.
The advantage is that more important jobs could be given more time, in other words, higher priority in treatment. The conse- quence, of course, is that shorter jobs will suffer. Allot a longer amount of time to processes deserving higher pri- ority. In other words, have two or more quantums possible in the Round-Robin scheme. Also assume that the context switching overhead is 0. What is the CPU utilization for a round-robin scheduler when: The time quantum is 1 millisecond b.
The time quantum is 10 milliseconds Answer: Irrespective of which process is scheduled, the scheduler incurs a 0. Exercises 31 5.
The program could maximize the CPU time allocated to it by not fully utilizing its time quantums. It could use a large fraction of its assigned quantum, but relinquish the CPU before the end of the quantum, thereby increasing the priority associated with the process.
Larger priority numbers imply higher priority. All processes are given a priority of 0 when they enter the ready queue.
FCFS b. LIFO 5. Multilevel feedback queues Answer: FCFS —discriminates against short jobs since any short jobs arriv- ing after long jobs will have a longer waiting time. 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.
Multilevel feedback queues—work similar to the RR algorithm— they discriminate favorably toward short jobs. What is the time quantum in milliseconds for a thread with priority 10? With priority 55? Assume a thread with priority 35 has used its entire time quantum without blocking. What new priority will the scheduler assign this thread? The higher the number, the lower the priority.
The scheduler recalculates process priorities once per second using the following function: What will be the new priorities for these three processes when priorities are recalculated? The priorities assigned to the processes are 80, 69, and 65 respectively.
The scheduler lowers the relative priority of CPU-bound processes. Concurrency is generally very hard for students to deal with correctly, and so we have tried to introduce it and its problems with the classic process coordination problems: An understanding of these problems and their solutions is part of current operating-system theory and development. We first use semaphores and monitors to introduce synchronization tech- niques. Next, Java synchronization is introduced to further demonstrate a language-based synchronization technique.
We conclude with a discussion of how contemporary operating systems provide features for process synchro- nization and thread safety. Exercises 6. The two processes, P0 and P1 , share the following variables: Prove that the algorithm satisfies all three requirements for the critical-section problem.
This algorithm satisfies the three conditions of mutual ex- clusion. If both processes set their flag to true, only one will succeed. Namely, the process whose turn it is. The waiting process can only enter its critical section when the other process updates the value of turn. This algorithm does not provide strict alternation.
It only sets turn to the value of the other process upon exiting its critical section. If this process wishes to enter its critical section again - before the other process - it repeats the process of entering its critical section and setting turn to the other process upon exiting.
Assume two processes wish to enter their respec- tive critical sections. They both set their value of flag to true, however only the thread whose turn it is can proceed, the other thread waits.
If bounded waiting were not preserved, it would therefore be possible that the waiting process would have to wait indefinitely while the first process repeatedly entered - and exited - its critical section.
The processes share the following variables: The structure of process Pi is shown in Figure 6. This algorithm satisfies the three conditions. Before we show that the three conditions are satisfied, we give a brief explanation of what the algorithm does to ensure mutual exclusion. When a process i requires access to critical section, it first sets its flag variable to want in to indicate its desire.
It then performs the following steps: Given the above description, we can reason about how the algorithm satisfies the requirements in the following manner: Notice that a process enters the critical section only if the following requirements is satisfied: Since the process sets its own flag variable set to in cs before checking the status of other processes, we are guaranteed that no two processes will enter the critical section simultaneously.
When this happens, all processes realize that there are competing processes, enter the next iteration of the outer while 1 loop and reset their flag variables to want in. Now the only process that will set its turn variable to in cs is the process whose index is closest to turn.
It is however possible that new processes whose index values are even closer to turn might decide to enter the critical section at this point and therefore might be able to simultaneously set its flag to in cs. These processes would then realize there are competing processes and might restart the process of entering the critical section. However, at each iteration, the index values of processes that set their flag variables to in cs become closer to turn and eventually we reach the following condition: This process then gets to enter the critical section.
The bounded waiting requirement is satisfied by the fact that when a process k desires to enter the critical section, its flag is no longer set to idle. Therefore, any process whose index does not lie between turn and k cannot enter the critical section. In the meantime, all processes whose index falls between turn and k and desire to enter the critical section would indeed enter the critical section due to the fact that the system always makes progress and the turn value monotonically becomes closer to k.
Eventually, either turn becomes k or there are no processes whose index values lie between turn and k, and therefore process k gets to enter the critical section.
What other kinds of waiting are there in an operating system? Can busy waiting be avoided altogether? Busy waiting means that a process is waiting for a condition to be satisfied in a tight loop without relinquish the processor. Alternatively, a process could wait by relinquishing the processor, and block on a condition and wait to be awakened at some appropriate time in the future. Busy waiting can be avoided but incurs the overhead associated with putting a process to sleep and having to wake it up when the appropriate program state is reached.
Spinlocks are not appropriate for single-processor systems because the condition that would break a process out of the spinlock could be obtained only by executing a different process.
If the process is not relinquishing the processor, other processes do not get the opportu- nity to set the program condition required for the first process to make progress.
In a multiprocessor system, other processes execute on other processors and thereby modify the program state in order to release the first process from the spinlock. If a user-level program is given the ability to disable interrupts, then it can disable the timer interrupt and prevent context switching from taking place, thereby allowing it to use the processor without letting other processes to execute. Interrupts are not sufficient in multiprocessor systems since disabling interrupts only prevents other processes from executing on the processor in which interrupts were disabled; there are no limitations on what processes could be executing on other processors and therefore the process disabling interrupts cannot guarantee mutually exclusive access to program state.
For example, a server may wish to have only N socket connections at any point in time. As soon as N connections are made, the server will not accept another incoming connection until an existing connection is re- leased. Explain how semaphores can be used by a server to limit the number of concurrent connections. A semaphore is initialized to the number of allowable open socket connections. When a connection is accepted, the acquire method is called, when a connection is released, the release method is called.
A wait operation atomically decrements the value associated with a semaphore. If two wait operations are executed on a semaphore when its value is 1, if the two operations are not performed atomically, then it is possible that both operations might proceed to decrement the semaphore value thereby violating mutual exclusion.
The solution should exhibit minimal busy waiting. Here is the pseudocode for implementing the operations: A barbershop consists of a waiting room with n chairs and a barber room with one barber chair.
If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber.
Write a program to coordinate the barber and the customers. A semaphore can be implemented using the following monitor code: Each condition variable is represented by a queue of threads waiting for the condition. Each thread has a semaphore associated with its queue entry. When a thread performs a wait operation, it creates a new semaphore initialized to zero , appends the semaphore to the queue associated with the condition variable, and performs a blocking semaphore decrement operation on the newly created semaphore.
When a thread performs a signal on a condition variable, the first process in the queue is awakened by performing an increment on the corresponding semaphore. Explain why this is true.
Design a new scheme that is suitable for larger portions. These copy operations could be expensive if one were using large extents of memory for each buffer region. The increased cost of copy operation means that the monitor is held for a longer period of time while a process is in the produce or consume operation.
This decreases the overall throughput of the system. This problem could be alleviated by storing pointers to buffer regions within the monitor instead of storing the buffer regions themselves.
This operation should be relatively inexpensive and therefore the period of time that the monitor is being held will be much shorter, thereby increasing the throughput of the monitor. Propose a method for solving the readers- writers problem without causing starvation. Throughput in the readers-writers problem is increased by favoring multiple readers as opposed to allowing a single writer to exclusively access the shared values. On the other hand, favoring readers could result in starvation for writers.
The starvation in the readers- writers problem could be avoided by keeping timestamps associated with waiting processes. When a writer is finished with its task, it would wake up the process that has been waiting for the longest duration. When a reader arrives and notices that another reader is accessing the database, then it would enter the critical section only if there are no waiting writers.
These restrictions would guarantee fairness. The signal operations associated with monitors is not persistent in the following sense: If a subsequent wait operation is performed, then the corresponding thread simply blocks. A future wait operation would immediately succeed because of the earlier increment. Suggest how the implementation described in Section 6. If the signal operation were the last statement, then the lock could be transferred from the signalling process to the process that is the recipient of the signal.
Otherwise, the signalling process would have to explicitly release the lock and the recipient of the signal would have to compete with all other processes to obtain the lock to make progress. Write a monitor that allocates three identical line printers to these processes, using the priority numbers for deciding the order of allocation. Here is the pseudocode: The sum of all unique numbers associated with all the processes currently accessing the file must be less than n.
Write a monitor to coordinate access to the file. The pseudocode is as follows: How would the solution to the preceding exercise differ with the two different ways in which signaling can be performed?
The solution to the previous exercise is correct under both situations. However, it could suffer from the problem that a process might be awakened only to find that it is still not possible for it to make forward progress either because there was not sufficient slack to begin with when a process was awakened or if an intervening process gets control, obtains the monitor and starts accessing the file.
Also, note that the broadcast operation wakes up all of the waiting processes. If the signal also transfers control and the monitor from the current thread to the target, then one could check whether the target would indeed be able to make forward progress and perform the signal only if it it were possible.
Write a monitor using this scheme to implement the readers— writers problem. Explain why, in general, this construct cannot be implemented efficiently. What restrictions need to be put on the await statement so that it can be implemented efficiently? Restrict the generality of B; see Kessels . This requires considerable complexity as well as might require some interaction with the compiler to evaluate the conditions at different points in time.
One could restrict the boolean condition to be a disjunction of conjunctions with each component being a simple check equality or inequality with respect to a static value on a program variable. In that case, the boolean condition could be communicated to the runtime system, which could perform the check every time it needs to determine which thread to be awakened. You may assume the existence of a real hardware clock that invokes a procedure tick in your monitor at regular intervals.
Here is a pseudocode for implementing this: Solaris, Linux, and Windows use spinlocks as a syn- chronization mechanism only on multiprocessor systems. In a multipro- cessor system, other processes execute on other processors and thereby modify the program state in order to release the first process from the spinlock.
Why is this restriction necessary? If the transaction needs to be aborted, then the values of the updated data values need to be rolled back to the old values. This requires the old values of the data entries to be logged before the updates are performed. A schedule refers to the execution sequence of the operations for one or more transactions. A serial schedule is the situation where each transaction of a schedule is performed atomically.
If a schedule consists of two different transactions where consecutive operations from the different transactions access the same data and at least one of the operations is a write, then we have what is known as a conflict.
If a schedule can be transformed into a serial schedule by a series of swaps on nonconflicting operations, we say that such a schedule is conflict serializable. The two-phase locking protocol ensures conflict serializabilty because exclusive locks which are used for write operations must be acquired serially, without releasing any locks during the acquire growing phase. Other transactions that wish to acquire the same locks must wait for the first transaction to begin releasing locks.
By requiring that all locks must first be acquired before releasing any locks, we are ensuring that potential conflicts are avoided. How does the system process transactions that were issued after the rolled-back transaction but that have timestamps smaller than the new timestamp of the rolled-back transaction?
If the transactions that were issued after the rolled-back trans- action had accessed variables that were updated by the rolled-back trans- action, then these transactions would have to rolled-back as well. If they have not performed such operations that is, there is no overlap with the rolled-back transaction in terms of the variables accessed , then these operations are free to commit when appropriate.
Processes may ask for a number of these resources and —once finished —will return them. As an example, many commercial software packages provide a given number of licenses, indicating the number of applications that may run concurrently.
When the application is started, the license count is decremented. When the application is terminated, the license count is incremented. If all licenses are in use, requests to start the application are denied. Such requests will only be granted when an existing license holder terminates the application and a license is returned.
The maximum number of resources and the number of available resources are declared as follows: Do the fol- lowing: Identify the data involved in the race condition. Identify the location or locations in the code where the race condition occurs. Using a semaphore, fix the race condition. The variable available resources. The code that decrements available resources and the code that increments available resources are the statements that could be involved in race conditions. Use a semaphore to represent the available resources variable and replace increment and decrement operations by semaphore increment and semaphore decrement operations.
This leads to awkward programming for a process that wishes obtain a number of resources: This will allow a process to invoke decrease count by simply calling decrease count count ; The process will only return from this function call when sufficient resources are available. It is important that the students learn the three basic approaches to deadlock: It can be useful to pose a deadlock problem in human terms and ask why human systems never deadlock.
Can the students transfer this understanding of human systems to computer systems? Projects can involve simulation: Ask the students to al- locate the resources to prevent deadlock.
The survey paper by Coffman, Elphick, and Shoshani  is good sup- plemental reading, but you might also consider having the students go back to the papers by Havender , Habermann , and Holt [a]. The last two were published in CACM and so should be readily available. Exercises 7. Show that the four necessary conditions for deadlock indeed hold in this example. State a simple rule for avoiding deadlocks in this system.
The four necessary conditions for a deadlock are 1 mutual exclu- sion; 2 hold-and-wait; 3 no preemption; and 4 circular wait. The mutual exclusion condition holds as only one car can occupy a space in the roadway. A car cannot be removed i. Lastly, there is indeed a circular wait as each car is waiting for a subsequent car to advance.
The circular wait condition is also easily observed from the graphic. A simple rule that would avoid this traffic deadlock is that a car may not advance into an intersection if it is clear they will not be able to immediately clear the intersection.
Dis- cuss how the four necessary conditions for deadlock indeed hold in this setting. Discuss how deadlocks could be avoided by eliminating any one of the four conditions. Deadlock is possible because the four necessary conditions hold in the following manner: Deadlocks could be avoided by overcoming the conditions in the following manner: Exercises 49 7.
Such synchronization objects may include mutexes, semaphores, condition variables, etc. We can prevent the deadlock by adding a sixth object F. This solution is known as containment: Compare this scheme with the circular-wait scheme of Section 7. This is probably not a good solution because it yields too large a scope. It is better to define a locking policy with as narrow a scope as possible.
Runtime overheads b. System throughput Answer: A deadlock-avoidance scheme tends to increase the runtime overheads due to the cost of keep track of the current resource allocation.
However, a deadlock-avoidance scheme allows for more concurrent use of resources than schemes that statically prevent the formation of dead- lock. In that sense, a deadlock-avoidance scheme could increase system throughput. Resources break or are replaced, new processes come and go, new re- sources are bought and added to the system.
Increase Available new resources added. Decrease Available resource permanently removed from system c. Increase Max for one process the process needs more resources than allowed, it may want more d. Decrease Max for one process the process decides it does not need that many resources e.
Increase the number of processes.
Decrease the number of processes. Increase Available new resources added - This could safely be changed without any problems. Increase Max for one process the process needs more resources than allowed, it may want more - This could have an effect on the system and introduce the possibility of deadlock.
Decrease Max for one process the process decides it does not need that many resources - This could safely be changed without any problems. Increase the number of processes - This could be allowed assum- ing that resources were allocated to the new process es such that the system does not enter an unsafe state. Decrease the number of processes - This could safely be changed without any problems.
Show that the system is deadlock-free. 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. Resources can be requested and released by pro- cesses only one at a time. Show that the system is deadlock free if the following two conditions hold: The maximum need of each process is between 1 and m resources b. Using the terminology of Section 7.
Hence the system cannot be in a deadlock state. Assume that requests for chopsticks are made one at a time. The following rule prevents deadlock: Assume now that each philosopher requires three chopsticks to eat and that resource re- quests are still issued separately. Describe some simple rules for deter- mining whether a particular request could be satisfied without causing deadlock given the current allocation of chopsticks to philosophers.
When a philosopher makes a request for a chopstick, allocate the request if: Need A B C P0 7 4 3 P1 0 2 0 P2 6 0 0 P3 0 1 1 P4 4 3 1 If the value of Available is 2 3 0 , we can see that a request from process P0 for 0 2 0 cannot be satisfied as this lowers Available to 2 1 0 and no process could safely finish. What is the content of the matrix Need?
Is the system in a safe state? If a request from process P1 arrives for 0,4,2,0 , can the request be granted immediately? The values of Need for processes P0 through P4 respectively are 0, 0, 0, 0 , 0, 7, 5, 0 , 1, 0, 0, 2 , 0, 0, 2, 0 , and 0, 6, 4, 2. 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.
Yes it can. This results in the value of Available being 1, 1, 0, 0. How could this assumption be violated? The optimistic assumption is that there will not be any form of circular-wait in terms of resources allocated and processes making requests for them. This assumption could be violated if a circular-wait does indeed in practice.
Create n threads that request and release resources from the banker. A banker will only grant the request if it leaves the system in a safe state. Ensure that access to shared data is thread-safe by employing Java thread synchronization as discussed in Section 7. Farmers in the two villages use this bridge to deliver their produce to the neighboring town. The bridge can be- come deadlocked if both a northbound and a southbound farmer get on the bridge at the same time Vermont farmers are stubborn and are un- able to back up.
Using semaphores, design an algorithm that prevents deadlock. Initially, do not be concerned about starvation the situation in which northbound farmers prevent southbound farmers from using the bridge, or vice versa. We want the student to learn about all of them: Exercises 8. Internal Fragmentation is the area in a region or a page that is not used by the job occupying that region or page.
This space is unavailable for use by the system until that job is finished and the page or region is released. A compiler is used to generate the object code for individual modules, and a linkage editor is used to combine multiple object modules into a single program binary. How does the linkage editor change the binding of instructions and data to memory addresses? What information needs to be passed from the compiler to the linkage editor to facilitate the memory binding tasks of the linkage editor?
The linkage editor has to replace unresolved symbolic ad- dresses with the actual addresses associated with the variables in the final program binary. In order to perform this, the modules should keep track of instructions that refer to unresolved symbols. During linking, each module is assigned a sequence of addresses in the overall program binary and when this has been performed, unresolved references to sym- bols exported by this binary could be patched in other modules since every other module would contain the list of instructions that need to be patched.
Which algorithm makes the most efficient use of memory? Data allocated in the heap segments of programs is an example of such allocated memory. What is required to support dynamic memory allocation in the following schemes: Exercises 57 8. Pure segmentation also suffers from external fragmentation as a segment of a process is laid out contiguously in physical memory and fragmentation would occur as segments of dead processes are replaced by segments of new processes. Segmentation, however, enables processes to share code; for instance, two different processes could share a code segment but have distinct data segments.
Pure paging does not suffer from external frag- mentation, but instead suffers from internal fragmentation. Processes are allocated in page granularity and if a page is not completely utilized, it results in internal fragmentation and a corresponding wastage of space.
Paging also enables processes to share code at the granularity of pages. How could the operating system allow access to other memory? Why should it or should it not? An address on a paging system is a logical page number and an offset. The physical page is found by searching a table based on the logical page number to produce a physical page number.
Because the operating system controls the contents of this table, it can limit a process to accessing only those physical pages allocated to the process. There is no way for a process to refer to a page it does not own because the page will not be in the page table.
This is useful when two or more processes need to exchange data—they just read and write to the same physical addresses which may be at varying logical addresses. This makes for very efficient interprocess communication. Paging requires more memory overhead to maintain the trans- lation structures. Segmentation requires just two registers per segment: Paging on the other hand requires one entry per page, and this entry provides the physical address in which the page is located. Code is stored starting with a small fixed virtual address such as 0.
The code segment is followed by the data segment that is used for storing the program variables. When the program starts executing, the stack is allocated at the other end of the virtual address space and is allowed to grow towards lower virtual addresses.
What is the significance of the above structure on the following schemes: This could be much higher than the actual memory requirements of the process. When a program needs to extend the stack or the heap, it needs to allocate a new page but the corresponding page table entry is preallocated.
If a memory reference takes nanoseconds, how long does a paged memory reference take? If we add associative registers, and 75 percent of all page-table references are found in the associative registers, what is the effec- tive memory reference time? Assume that finding a page-table entry in the associative registers takes zero time, if the entry is there.
Segmentation and paging are often combined in order to im- prove upon each other. Segmented paging is helpful when the page table becomes very large. A large contiguous section of the page table that is unused can be collapsed into a single segment table entry with a page- table address of zero. Paged segmentation handles the case of having very long segments that require a lot of time for allocation. By paging the segments, we reduce wasted memory due to external fragmentation as well as simplify the allocation.
Exercises 59 8. Since segmentation is based on a logical division of memory rather than a physical one, segments of any size can be shared with only one entry in the segment tables of each user.
With paging there must be a common entry in the page tables for each page that is shared.At the software level, media must be checked for data consistency; for instance, do the number of allocated and unallocated blocks of storage match the total number on the device. Therefore, any process whose index does not lie between turn and k cannot enter the critical section. Exercises 3 1. The treatment is somewhat vague since more detail requires picking a specific system to discuss.
What is the main advantage for a user? If we are currently at logical block 10 the last block accessed was block 10 and want to access logical block 4, how many physical blocks must be read from the disk?
- THE SCI FI & FANTASY ART BOOK 4TH EDITION
- THE INTERPERSONAL COMMUNICATION BOOK 12TH EDITION
- COMPTIA A+ CERTIFICATION ALL-IN-ONE EXAM GUIDE 8TH EDITION PDF
- MANAGEMENT DAFT 11TH EDITION PDF
- LIPPINCOTT MANUAL OF NURSING PRACTICE 8TH EDITION PDF
- JOB INTERVIEW BOOK PDF
- CERSIL PENDEKAR NAGA PUTIH PDF
- PETER SINGER ANIMAL LIBERATION PDF
- KITAB HAKIKAT INSAN PDF
- PRACTICAL STRESS ANALYSIS WITH FINITE ELEMENTS PDF
- KHATRI OPERATIVE SURGERY MANUAL PDF