Sie sind auf Seite 1von 9

Exerccios do livro do William Stallings

Operating Systems, Internal and Design Principles


Operating Systems Overview Problems
1. Suppose that we have a multiprogrammed computer in which each job has
identical characteristics. In one computation period, T, for a job, half the time
is spent in I/O and the other half in processor activity. Each job runs for a
total of N periods. Assume that a simple round-robin scheduling is used, and
that I/O operations can overlap with processor operation. Define the following
quantities:
! Turnaround time = actual time to complete a job
! Throughput = average number of jobs completed per time period T
! Processor utilization = percentage of time that the processor is active (not
waiting)
Compute these quantities for one, two, and four simultaneous jobs, assuming that
the period T is distributed in each of the following ways:
a)

I/O first half, processor second half

b)

I/O first and fourth quarters, processor second and third quarter

2. An I/O-bound program is one that, if run alone, would spend more time waiting
for I/O than using the processor. A processor-bound program is the opposite.
Suppose a short-term scheduling algorithm favors those programs that have
used little processor time in the recent past. Explain why this algorithm favors
I/O-bound programs and yet does not permanently deny processor time to
processor-bound programs.
3. Contrast the scheduling policies you might use when trying to optimize a timesharing system with those you would use to optimize a multiprogrammed batch
system.
4. What is the purpose of system calls, and how do system calls relate to the OS
and to the concept of dual-mode (kernel mode and user mode) operation?

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles
Processes Review questions
1. What is an instruction trace?
2. What common events lead to the creation of a process?
3. For the processing model of the figure below, briefly define each state.

4. What does it mean to preempt a process?


5. What is swapping and what is its purpose?
6. Why does the figure below have two blocked states?

7. List 2 characteristics of a suspended process.


8. For what types of entities does the OS maintain tables of information for
management purposes?
9. List three general categories of information in a process control block.
10. Why are two modes (user and kernel) needed?
11. What are the steps performed by an OS to create a new process?
12. What is the difference between an interrupt and a trap?
13. Give three examples of an interrupt.
14. What is the difference between a mode switch and a process switch?

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles
Processes - Problems
1. Name five major activities of an OS with respect to process management, and
briefly describe why each is required.
2. In [PINK89], the following states are defined for processes: Execute
(running), Active (ready), Blocked, and Suspend. A process is blocked if it is
waiting for permission to use a resource, and it is suspended if it is waiting for
an operation to be completed on a resource it has already acquired. In many
operating systems, these two states are lumped together as the blocked state,
and the suspended state has the definition we have used in this chapter.
Compare the relative merits of the two sets of definitions.
3. For the seven-state process model, draw a queuing diagram similar to that of
Figure in question 4 (next question).
4. The figure below suggests that a process can only be in one Event queue at a
time.
Is it possible that you would want to allow a process to wait on more than
one event at the same time? Provide an example.
b) In that case, how would you modify the queuing structure of the figure to
support this new feature?
a)

5. In a number of early computers, an interrupt caused the register values to be


stored in fixed locations associated with the given interrupt signal. Under what
circumstances is this a practical technique? Explain why it is inconvenient in
general.

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles
Threads - Review questions
1. Table 3.5 lists typical elements found in a process control block for an
unthreaded OS. Of these, which should belong to a thread control block
and which should belong to a process control block for a multithreaded
system?
2. List reasons why a mode switch between threads may be cheaper than a
mode switch between processes.
3. What are the two separate and potentially independent characteristics
embodied in the concept of process?
4. What resources are typically shared by all of the threads of a process?
5. List advantages and disadvantages of ULTs over KLTs.

Threads - Problems
1. It was pointed out that two advantages of using multiple threads within a
process are that (1) less work is involved in creating a new thread within an
existing process than in creating a new process, and (2) communication
among threads within the same process is simplified. Is it also the case
that a mode switch between two threads within the same process involves
less work than a mode switch between two threads in different processes?
2. In the discussion of ULTs versus KLTs, it was pointed out that a
disadvantage of ULTs is that when a ULT executes a system call, not only is
that thread blocked, but also all of the threads within the process are
blocked. Why is that so?
3. Consider an environment in which there is a one-to-one mapping between
user-level threads and kernel-level threads that allows one or more threads
within a process to issue blocking system calls while other threads continue
to run. Explain why this model can make multithreaded programs run faster
than their single-threaded counterparts on a uniprocessor computer.
LEWI96-42
4. If a process exits and there are still threads of that process running, will
they continue to run? LEWI96-42

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles
Memory Management - Review questions

1. What requirements is memory management intended to satisfy?
2. Why is the capability to relocate processes desirable?
3. Why is it not possible to enforce memory protection at compile time?
4. What are some reasons to allow two or more processes to all have access to a
particular region of memory?
5. In a fixed-partitioning scheme, what are the advantages of using unequal-size
partitions?
6. What is the difference between internal and external fragmentation?
7. What are the distinctions among logical, relative, and physical addresses?
8. What is the difference between a page and a frame?
9. What is the difference between a page and a segment?

Memory Management Problems



1. Another placement algorithm for dynamic partitioning is referred to as worstfit. In this case, the largest free block of memory is used for bringing in a
process. Discuss the pros and cons of this method compared to first-, next-,
and best-fit.What is the average length of the search for worst-fit?
2. A virtual address a in a paging system is equivalent to a pair (p, w), in which p is
a page number and w is a byte number within the page. Let z be the number of
bytes in a page. Find algebraic equations that show p and w as functions of z
and a.

Exercises 7.1, 7.2 ... 7.6, 7.12, 7.13 (sixth Edition Stallings)

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles

Virtual Memory - Review questions



1. What is the difference between simple paging and virtual memory paging?
2. Explain thrashing.
3. Why is the principle of locality crucial to the use of virtual memory?
4. What elements are typically found in a page table entry? Briefly define each
element.
5. What is the purpose of a translation lookaside buffer?
6. Briefly define the alternative page fetch policies.
7. What is the difference between resident set management and page
replacement policy?
8. What is the relationship between FIFO and clock page replacement
algorithms?
9. What is accomplished by page buffering?
10. Why is it not possible to combine a global replacement policy and a fixed
allocation policy?
11. What is the difference between demand cleaning and precleaning?

Virtual Memory - Problems


1. Suppose the page table for the process currently executing on the processor
looks like the following. All numbers are decimal, everything is numbered
starting from zero, and all addresses are memory byte addresses.The page
size is 1024 bytes.
Virtual Page #

Valid bit

Reference Bit

Modify Bit

Page frame#

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles

a)

Describe exactly how, in general, a virtual address generated by the CPU is


translated into a physical main memory address.

b)

What physical address, if any, would each of the following virtual


addresses correspond to? (Do not try to handle any page faults, if any.)
(i)

1052

(ii)

2221

(iii)

5499

2. A process references five pages, A, B, C, D, and E, in the following order:


A; B; C; D; A; B; E; A; B; C; D; E

Assume that the replacement algorithm is first-in-first-out and find the number
of page transfers during this sequence of references starting with an empty main
memory with three page frames. Repeat for four page frames.

3. A process contains eight virtual pages on disk and is assigned a fixed allocation
of four page frames in main memory.The following page trace occurs:
1, 0, 2, 2, 1, 7, 6, 7, 0, 1, 2, 0, 3, 0, 4, 5, 1, 5, 2, 4, 5, 6, 7, 6, 7, 2, 4, 2, 7, 3, 3, 2, 3
a)

Show the successive pages residing in the four frames using the LRU
replacement policy. Compute the hit ratio in main memory.Assume that the
frames are initially empty.

b)

Repeat part (a) for the FIFO replacement policy.

c)

Compare the two hit ratios and comment on the effectiveness of using FIFO
to approximate LRU with respect to this particular trace.

4. Consider a paged logical address space (composed of 32 pages of 2 Kbytes


each) mapped into a 1-Mbyte physical memory space.
a)

What is the format of the processors logical address?

b)

What is the length and width of the page table (disregarding the access
rights bits)?

c)

What is the effect on the page table if the physical memory space is reduced
by half?

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles
Address mapping and Paging
Given the following logical address find the corresponding physical address. The
memory management scheme is paging with 16-bit addressing and frame size of
1024. Logical address: 0000101011110000
Page table
Page number

Frame number

101011

111100

110011

011010

010101

Address mapping and Segmentation


Given the following logical address find the corresponding physical address. The
memory management scheme is segmentation with 16-bit addressing and maximum
segment size of 4096. Logical address: 0011101011110000
Segment table
Segment number

Limit

Segment Base address

111011100101

1010111100001111

000100011010

1111000011001100

101010101010

1100111011001110

111101011111

0110101110101110

111000111000

0101010111111011

Exerccios do livro do William Stallings


Operating Systems, Internal and Design Principles
Assuming a 1-KB page size , What are the page numbers and offsets for the
following address references (provided as decimal numbers)

a)
b)
c)
d)
e)

2375
19366
30000
256
16385

Consider a computer system with a 32-bit logical address and 4-KB page size . The
system supports up to 512MB of physical memory. How many entries are there in a
page table?

Das könnte Ihnen auch gefallen