3.8 Describe the differences among short-term, medium-term, and long term scheduling.
Short term chooses the next process from the ready processes while the medium term scheduler chooses processes currently in memory and swaps them out to disk, which later on get swapped back. Short term processes select new processes often. Long term schedulers choose from a pool currently waiting on disk and must wait a while before selecting the next process.
3.9 Describe the actions taken by a kernel to context-switch between processes.
When an interrupt occurs the operating system saves the PC and user stack pointer for current processes and gives control to kernel. Then, the clock interrupt handler saves the remaining registers and machine states in the PCB. The OS asks the scheduler what the next process to execute is and then the OS retrieves the state of that process and restores the registers. At this point, we’re back to where we started.
4.6 Provide two programming examples in which multithreading does not provide better performance than a single-threaded solution.
A shell program like C-shell has to closely monitor its own workspace, so multithreading is not better here. Also a sequential program like one that calculates tax returns.
4.14 A system with two dual-core processors has four processors available for scheduling. A CPU-intensive application is running on this system. All input is performed at program start-up, when a single file must be opened. Similarly, all output is performed just before the program terminates, when the program results must be written to a single file. Between startup and termination, the program is entirely CPU bound. Your task is to improve the performance of this application by multithreading it. The application runs on a system that uses the one-to-one threading model (each user thread maps to a kernel thread).
Create enough threads to block system calls and no more to save efficiency – one thread for input and one for output.
Four because there should be as many threads as cores – any less is a waste of resources and more than that would not be able to run.
4.18 Consider a multicore system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be greater than the number of processing cores in the system. Discuss the performance implications of the following scenarios.
Some processes will be idle because the scheduler can only map kernel threads to processors – not user level threads.
All processors may be used at the same time but a kernel thread blocking inside the kernel could cause a processor to be idle.
A blocked kernel thread here can be swapped for another that is available and ready
6.16 Consider the following set of processes, with the length of the CPU burst given in milliseconds:
Process |
Burst Time |
Priority |
P1 |
2 |
2 |
P2 |
1 |
1 |
P3 |
8 |
4 |
P4 |
4 |
2 |
P5 |
5 |
3 |
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
FCFS
1 |
2 |
3 |
4 |
5 |
RR
1 |
2 |
3 |
4 |
5 |
1 |
3 |
5 |
1 |
5 |
1 |
5 |
1 |
5 |
1 |
SJF
2 |
4 |
3 |
5 |
1 |
Priority
2 |
5 |
1 |
3 |
4 |
FCFS |
RR |
SJF |
Priority |
|
P1 |
10 |
19 |
19 |
16 |
P2 |
11 |
2 |
1 |
1 |
P3 |
13 |
7 |
4 |
18 |
P4 |
14 |
4 |
2 |
19 |
P5 |
19 |
14 |
9 |
6 |
FCFS |
RR |
SJF |
Priority |
|
P1 |
0 |
9 |
9 |
6 |
P2 |
10 |
1 |
0 |
0 |
P3 |
11 |
5 |
2 |
16 |
P4 |
13 |
3 |
1 |
18 |
P5 |
14 |
9 |
4 |
1 |
Shortest job first
6.20 Consider a variant of the RR scheduling algorithm in which the entries in the ready queue are pointers to the PCBs.
Essentially increasing the priority of the process by giving it more attention
Advantages – more important jobs are given higher priority and it prevents starvation of lower priority ones
Disadvantages – context switching has greater effects and it is more difficult to remove running processes.
Have two or more quantums possible to give more time to processes that should get higher priority.
6.24 Explain the differences in how much the following scheduling algorithms discriminate in favor of short processes:
Discriminates short jobs because after longer jobs they have had a long wait time.
All jobs are treated equal so short jobs leave sooner because they finish first.
Like RR, they discriminate in favor of short jobs.
Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak: Sheryl. Read More
Follow Us