Вы находитесь на странице: 1из 4

Rikelmi Marte

Chapter 4

1. Figure 4.12 is a simplified process model of you, in which there are only two
states: sleeping and waking. You make the transition from waking to sleeping
when you are tired, and from sleeping to waking when the alarm clock goes off.

a. Add three more states to the diagram (for example, one might be eating).

b. State all of the possible transitions among the five states.

- SUSPEND BLOCKED then BLOCKED if a process in


the RUNNING state requires more memory, then at least one BLOCKED process
can be swapped out of memory onto disk. The transition can also be made for
the BLOCKED process if there are READY processes available, and the OS
determines that the READY process that it would like to dispatch requires more
main memory to maintain adequate performance.
- SUSPEND BLOCKED then SUSPEND READY A process in
the SUSPEND BLOCKED state is moved to the SUSPEND READY state when
the event for which it has been waiting occurs. Note that this requires that the
state information concerning suspended processes be accessible to the OS.
- SUSPEND READY then READY when there are no READY processes in
main memory, the OS will need to bring one in to continue execution. In addition,
it might be the case that a process in the READY SUSPEND state has higher
priority than any of the processes in the READY state. In that case, the OS
designer may dictate that it is more important to get at the higher priority process
than to minimize swapping.
- SUSPENDED but READY normally, the OS would be designed so that
the preference would be to suspend a BLOCKED process rather

2. Describe context switching in lay terms and identify the process information
that needs to be saved, changed, or updated when context switching takes place.

Context switching is a hardware-dependent operation whose implementation is


inuenced by the underlying hardware facilities. Some architecture provides machine
instructions that save and restore the hardware-execution context of the process,
including the virtual-address space. On the others, the software must collect the
hardware state from various registers and save it, then load those registers with the new
hardware state. All architectures must save and restore the software state used by the
kernel.
Context switching is done frequently, so increasing the speed of a context switch
noticeably decreases time spent in the kernel and provides more time for execution of
user applications. Since most of the work of a context switch is expended in saving and
restoring the operating context of a process, reducing the amount of the information
required for that context is an effective way to produce faster context switches.

3. Five jobs (A, B, C, D, E) are already in the READY queue waiting to be


processed. Their estimated CPU cycles are respectively: 2, 10, 15, 6, and 8.
Using SJN, in what order should they be processed?

A
D
E
B
C

4. A job running in a system, with variable time quantums per queue, needs 30
milliseconds to run to completion. If the first queue has a time quantum of 5
milliseconds and each queue thereafter has a time quantum that is twice as large
as the previous one, how many times will the job be interrupted and on which
queue will it finish its execution?

Examine the low order quanta queues: 5 x 20 + 5 x 21 + 5 x 22 = 5 + 10 + 20 = 35

The job will be interrupted twice, and will finish on the 20 millisecond queue.

5. Describe the advantages of having a separate queue for Print I/O and for Disk
I/O as illustrated in Figure 4.4

Flexibility

Operating system-level virtualization is not as flexible as other virtualization


approaches since it cannot host a guest operating system different from the host one,
or a different guest kernel. For example, with Linux, different distributions are fine,
but other OS such as Windows cannot be hosted. This limitation is partially overcome
in Solaris by its branded zones feature, which provides the ability to run an
environment within a container that emulates an older Solaris 8 or 9 version in a
Solaris 10 host. (a Linux branded zone was also announced and implemented for some
Linux kernels, but later abandoned).
Storage

Some operating-system virtualizers provide file-level copy-on-write mechanisms.


(Most commonly, a standard file system is shared between partitions, and partitions
which change the files automatically create their own copies.) This is easier to back
up, more space-efficient and simpler to cache than the block-level copy-on-write
schemes common on whole-system virtualizers. Whole-system virtualizers, however,
can work with non-native file systems and create and roll back snapshots of the entire
system state.

6. Given the following information:


Job Arrival Time CPU Cycle
A 0 2
B 1 12
C 2 4
D 4 1
E 5 8
F 7 5
G 8 3
Using SJN, draw a timeline showing the time that each job arrives and the order that
each is processed. Calculate the finish time for each job.

JOBS D A G C F E B
0 1 2 3 4 5 8
12

1+2+3+4+5+8+12/7 = 5.0

7. Given the following information:


Job Arrival Time CPU Cycle
A 0 10
B 2 12
C 3 3
D 6 1
E 9 15
Draw a timeline for each of the following scheduling algorithms. (It may be helpful to first
compute a start and finish time for each job.)
a. FCFS
b. SJN
JOBS D C A B E
0 1 3 10 12
15

1+3+10+12+15/5=8.2

c. SRT
d. Round robin (using a time quantum of 5, ignore context switching and natural wait)

8. Using the same information from Exercise 7, calculate which jobs will have arrived ready for processing by the time the
first job is finished or interrupted using each of the following scheduling algorithms.
a. FCFS
b. SJN
c. SRT
d. Round robin (using a time quantum of 5, ignore context switching and natural wait)

Вам также может понравиться