Sei sulla pagina 1di 13

1. Discuss how the following pairs of scheduling criteria conflict in certain settings.

(unit 1)
a. CPU utilization and response time
b. Average turnaround time and maximum waiting time
c. I/O device utilization and CPU utilization

Answer:

• CPU utilization and response time: 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 and maximum waiting time: 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.

• I/O device utilization and CPU utilization: CPU utilization is maximized by running
long-running CPU-bound tasks without performing context switches. I/O device
utilization is maximized by scheduling I/O-bound jobs as soon as they become
ready to run, thereby incurring the overheads of context switches.

2.Consider a variant of the RR scheduling algorithm where the entries in the


ready
queue are pointers to the PCBs (unit 1)

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?

Solution:
a) In effect, that process will have increased its priority since by getting time more
often it is receiveing preferentail treatment.
b) The advantage is that more important jobs could be given more time, in other
words, higher priority in treatment. The consequence, of course, is that shorter
jobs will suffer.

c) Allot a longer amount of time to processes deserving higher priority, on other


words, have two ro more quantums possible in the RR scheme.

3. Consider the following page-replacement algorithms. Rank these


algorithms on a five-point scale from 'bad' to 'perfect' according
to their page-fault rate. Separate those algorithms that suffer from
Belady's anomaly from those that do not.(unit 2)

4.Compare the main memory organization schemes of contiguous memory


allocation, pure segmentation, and pure paging with respect to the following
issues: a. external fragmentation b. internal fragmentation c. ability to share code
across processes(unit 2)

Answer:
The contiguous memory allocation scheme suffers from external fragmentation as
address spaces are allocated contiguously and holes develop as old processes die
and new processes are initiated. It also does not allow processes to share code,
since a process’s virtual memory segment is not broken into noncontiguous fine
grained segments. 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 fragmentation,
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

5. Why are page sizes always powers of 2? Consider a logical address space of
eight pages of 1024 words each, mapped onto a physical memory of 32 frames.
(unit 2)

a. How many bits are there in the logical address?

b. How many bits are there in the physical address?

->The bytes within a page are addressed using the last N bits of a virtual address,
for some value of N. Since the number of addresses that can be expressed with N
bits is 2N, the page size is a power of 2.
Addressing within a 1024-word page requires 10 bits because 1024 = 2 10. Since
the logical address space consists of 8 = 23 pages, the logical addresses must be
10+3 = 13 bits. Similarly, since there are 32 = 25physical pages, phyiscal addresses
are 5 + 10 = 15 bits long.

Physical Address (P = page number bits)

P P P P P - - - - - - - - - -

Logical Address (P = page number bits)


P P P - - - - - - - - - -
.
6.Consider a file system that uses inodes to represent files. Disk blocks are 8-KB in
size and a pointer to a disk block requires 4 bytes. This file system has 12 direct
disk blocks, plus single, double, and triple indirect disk blocks. What is the
maximum size of a file that can be stored in this file system?

Answer:
(12 * 8 /KB/) + (2048 * 8 /KB) + (2048 * 2048 * 8 /KB/) + (2048 * 2048 * 2048 *
8 /KB) = 64 terabytes

7. Consider a system that supports the strategies of contiguous, linked, and


indexed allocation. What criteria should be used in deciding which strategy is best
utilized for a particular file?

Answer: •
Contiguous—if file is usually accessed sequentially, if file is relatively small.
Linked—if file is large and usually accessed sequentially.
Indexed—if file is large and usually accessed randomly.
8. Given five memory partitions of 100Kb, 500Kb, 200Kb, 300Kb, 600Kb (in order),
how would the first-fit, best-fit, and worst-fit algorithms place
processes of 212 Kb, 417 Kb, 112 Kb, and 426 Kb (in order)? Which algorithm
makes the most efficient use of memory?

First-fit:
212K is put in 500K partition
417K is put in 600K partition
112K is put in 288K partition (new partition 288K = 500K - 212K)
426K must wait

Best-fit:
212K is put in 300K partition
417K is put in 500K partition
112K is put in 200K partition
426K is put in 600K partition

Worst-fit:
212K is put in 600K partition
417K is put in 500K partition
112K is put in 388K partition
426K must wait

In this example, best-fit turns out to be the best.


9.Consider a swapping system in
which memory consists of the
following hole sizes in memory
order: 10MB, 4MB, 20MB, 18MB,
7MB, 9MB, 12MB, and
15MB. Which hole is taken for
successive segment requests of
(a) 12 MB
(b) 10 MB
(c) 9 MB
for first fit? Now repeat the question
for best fit, worst fit, and next fit.
Consider a swapping
system in which
memory consists of
the
following hole sizes
in memory order:
10MB, 4MB, 20MB,
18MB, 7MB, 9MB,
12MB, and
15MB. Which hole is
taken for successive
segment requests of
(a) 12 MB
(b) 10 MB
(c) 9 MB
for first fit? Now
repeat the question
for best fit, worst fit,
and next fit.
Consider a swapping
system in which
memory consists of
the
following hole sizes
in memory order:
10MB, 4MB, 20MB,
18MB, 7MB, 9MB,
12MB, and
15MB. Which hole is
taken for successive
segment requests of
(a) 12 MB
(b) 10 MB
(c) 9 MB
for first fit? Now
repeat the question
for best fit, worst fit,
and next fit.
9.
10. Disk requests come to a disk driver for cylinders in the order 10, 22, 20, 2, 40,
6 and 38 at a given time when the given disk drive is reading from cylinder 20. The
seek time is 6ms per cylinder.
1.fcfs
2.closed cylinder next

1. FCFS
Total seek time
= 10*6 + 12*6 + 2*6 + 18*6+ 38 * 6 + 34*6 + 32*6
= 146*6
= 876 ms

2. Closest cylinder next:


Here the service order will be
20 22 10 6 2 38 40
So, total seek time
= (0 + 2 + 12 + 4 + 4 + 36 + 2) * 6
= 60 * 6
= 360
11. Five batch jobs A through E, arrive at a computer center at almost the same
time. They have estimated running times of 11, 6, 2, 4, and 8 minutes. Their
(externally determined) priorities are 3, 5, 2, 1, and 4, respectively, with 5 being
the highest priority. For each of the following scheduling algorithms, determine
the mean process turnaround time. Ignore process switching overhead.
(a) Round-robin
(b) Priority scheduling
(c) First come, First served (run in order 11, 6, 2, 4, 8)
(d) Shortest job first For (a), assume that the system is multiprogrammed, and that
each job gets its fair share of the CPU. For (b) through (d) assume that only one
job runs at a time, until it finishes. All jobs are completely CPU bound. Assume
that the time quantum of the scheduler is 1 minute.

Answer: Remember that the turnaround time is the amount of time that elapses
between the job arriving and the job completing. Since we assume that all jobs
arrive at time 0, the turnaround time will simply be the time that they complete.
(a) Round Robin: The table below gives a break down of which jobs will be
processed during each time quantum. A * indicates that the job completes
during that quantum.

Potrebbero piacerti anche