or

or

taken

why

Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.

Don't know
Know
remaining cards
Save
0:01

 Flashcards Matching Hangman Crossword Type In Quiz Test StudyStack Study Table Bug Match Hungry Bug Unscramble Chopped Targets

Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

Normal Size     Small Size show me how

### Operating Systems: Processes and Threads (Ch. 2)

ProblemSolution
In Fig. 2-2, three process states are shown. In theory, with three states, there could be six transitions. However, only four transitions are shown. Are there any circumstances in which blocked-->running might occur? It is conceivable. If all processes in the system are blocked on I/O and one I/O completes, this process could run immediately. However, you could also say the process became ready when I/O completes and then the scheduler immediately runs it.
In Fig. 2-2, three process states are shown. In theory, with three states, there could be six transitions. However, only four transitions are shown. Are there any circumstances in which ready-->blocked might occur? A transition from ready to blocked is not possible. A ready process is not running so cannot do I/O or anything else that might block it. It needs to run first.
What is the key difference between a trap and an interrupt? A trap is caused by the program. If the program is run again and again, the trap will always occur at exactly the same position. An interrupt is caused by an external event and its time is not reproducible.
Multiple jobs can run in parallel and finish faster than sequentially. Suppose that two jobs, each of which needs 10min of CPU time, start simultaneously. How long with the last one take to complete if they run sequentially? Assume 50% I/O wait. If each job has 50% I/O wait, the it will take 20 minutes complete in the absence of competition. If run sequentially, the second one will finish 40 minutes after the first one starts.
Multiple jobs can run in parallel and finish faster than if they had run sequentially. Suppose that two jobs, each of which needs 10 minutes of CPU time, start simultaneously. How log if they run in parallel? Assume 50% I/O wait. With two jobs, the approximate CPU utilization is 1-0.52. Thus each one gets 0.375 CPU minutes per minute of real time. To accumulate 10 minutes of CPU time, a job must run for 10/0.375 minutes or about 26.67 minutes.
Why would a thread ever voluntarily give up the CPU by calling thread_yield? After all, since there is no periodic clock interrupt, it may never get back the CPU? Threads in a process cooperate. They are not hostile to one another. If yielding is needed for the good of the application, then a thread will yield. After all, it is usually the same programmer who writes the code for all the threads in one process.
Can a thread ever be preempted by a clock interrupt. If so, under what circumstances? If not, why not. Certainly kernel-level threads can be preempted. A user-level thread itself is not kernel-visible so is not preemptable, but the process (or kernel-level thread) running this user-level thread can be preempted.
What is the biggest advantage of implementing threads in user space? What is the biggest disadvantage. The biggest advantage is that no OS modification is needed. The biggest disadvantage is that when a blocking system call or a page fault occurs, all the threads in the process are blocked.
In section 2.3.4, a situation with a high-priority process, H, and a low-priority process, L, was described, which led to H looping forever. Does the same problem occur if round-robin scheduling is used instead of priority scheduling? With rr scheduling it works. Eventually L will run and leave its critical section. With priority scheduling, L never gets to run at all; with round robin, it gets a normal time slice periodically, so it has the chance to leave its critical section.
Measurements of a system show the average process runs for (T) time before blocking. Process switch requires (S) time. For round-robin scheduling with (Q) quantum, give the formula for CPU efficiency for: Q=∞ The CPU efficiency is the useful time divided by the total CPU time. When Q=∞, the basic cycle is for the process to run for T and undergo a process switch for S. Thus the efficiency is (T)/(S+T).
Measurements of a system show the average process runs for (T) time before blocking. Process switch requires (S) time. For round-robin scheduling with (Q) quantum, give the formula for CPU efficiency for: Q>T The CPU efficiency is the useful time divided by the total CPU time. When Q>T, the basic cycle is for the process to run for T and undergo a process switch for S. Thus the efficiency is (T)/(S+T).
Measurements of a system show the average process runs for (T) time before blocking. Process switch requires (S) time. For round-robin scheduling with (Q) quantum, give the formula for CPU efficiency for: S<Q<T The CPU efficiency is the useful time divided by the total CPU time. When the quantum is shorter than T, each run of T will requires T/Q process switches, wasting a time ST/Q. The efficiency is then T/(T+ST/Q), which reduces to Q/(Q+S).
Measurements of a system show the average process runs for (T) time before blocking. Process switch requires (S) time. For round-robin scheduling with (Q) quantum, give the formula for CPU efficiency for: Q=S The CPU efficiency is the useful time divided by the total CPU time. Simply substitute Q for S and find that the efficiency is 50%.
Measurements of a system show the average process runs for (T) time before blocking. Process switch requires (S) time. For round-robin scheduling with (Q) quantum, give the formula for CPU efficiency for: Q nearly 0 The CPU efficiency is the useful time divided by the total CPU time. As Q approaches 0 the efficiency goes to 0.
Round-robin schedulers normally maintain a list of all runnable processes, with each process occurring exactly once in the list. What would happen if a process occurred in the list? Can you think of any reason for allowing this? If a process occurs multiple times in the list, it will get multiple quanta per cycle. This approach could be used to give more important processes a larger share of the CPU.
Give an argument favoring a large quantum; give an argument favoring a small quantum. A large quantum is more efficient, since fewer process switches occur. On the other hand, interactive response time suffers, since the average case delay until a process that has just become read gets to run goes up linearly with the size of the quantum.
If a process needed T sec to complete in the absence of competition, how much time would it need if processor sharing was used with n processes? It will need nT sec.
Five jobs are waiting to be run. Their expected run times are 9, 6, 3, 5, and X. In what order should they be run in order to minimize average response time? (Your answer will depend on X.) Shortest Job First is the way to minimize average response time. 0 < x <= 3 : x, 3, 5, 6, 9. 3 < x <= 5 : 3, x, 5, 6, 9. 5 < x <= 6 : 3, 5, x, 6, 9. 6 < x <= 9 : 3, 5, 6, x, 9. 9 < x : 3, 5, 6, 9, x.
Five jobs A through E arrive at computer at the same time. The have run times [10, 6, 2, 4, 8]. Their priorities are [3, 5, 2, 1, 4] with 5 highest priority. For round-robin scheduling, determine the mean process turnaround time. In first 10min each job gets 1/5 of CPU. After 10min, C finishes. In next 8min, each job gets 1/4 of CPU, after which D finishes. Then remaining jobs get 1/3 of CPU for 6min, etc.. The finishing times are 10, 18, 24, 28, and 30, (avg. 22min).
Five jobs A through E arrive at computer at the same time. The have run times [10, 6, 2, 4, 8]. Their priorities are [3, 5, 2, 1, 4] with 5 highest priority. For priority scheduling, determine the mean process turnaround time. B is run first. After 6 minutes it is finished. The other jobs finish at 14, 24, 26, and 30, for an average of 20 minutes.
Five jobs A through E arrive at computer at the same time. The have run times [10, 6, 2, 4, 8]. Their priorities are [3, 5, 2, 1, 4] with 5 highest priority. For FCFS scheduling, determine the mean process turnaround time. they finish at 10, 16, 18, 22, and 30, for an average of 19.2 minutes.
Five jobs A through E arrive at computer at the same time. The have run times [10, 6, 2, 4, 8]. Their priorities are [3, 5, 2, 1, 4] with 5 highest priority. For shortest-job-first scheduling, determine the mean process turnaround time. shortest job first yields finishing times of 2, 6, 12, 20, and 30, for and average of 14 minutes.
Explain the difference between busy waiting and blocking process synchronization. With busy waiting, process keeps testing for condition. Constantly using CPU, sitting in tight loop. With blocking, process gives up CPU and awakened later when condition it is waiting for has become true. A blocked process does not use the CPU.
In the solution to the dining philosophers problem, why is the state variable set to HUNGRY int the procedure take_forks? If a philosopher blocks, neighbors can later see that he is hungry by checking his state, in test, so he can be awakened when the forks are available.
Consider the procedure put_forks. Suppose that the variable state[i] was set to THINKING after the two calls to test, rather than before. How would this change affect the solution? The change would mean that after a philosopher J stopped eating, neither of his or her neighbors could be chosen if they were hungry. The reason is that when J tests to see if his right or left neighbor can eat, the test will find J still eating.
PROCESSES PROBLEM PROCESSES PROBLEM
PROCESSES REDO PROBLEM PROCESSES REDO PROBLEM
Created by: JJFresh814