PART8
PART8
Computer Organization
and Architecture
10th Edition
Edited by
Dr. George Lazik
+ Chapter 8
Operating System Support
Memory
System interconnect
translation Hardware
(bus)
I/O devices
Main
and
memory
networking
Programs
and Data
I/O Controller
Processor Processor
Storage
OS
Programs
Data
Interactive system
The user/programmer interacts directly with the computer to
request the execution of a job or to perform a transaction
User may, depending on the nature of the application,
communicate with the computer during the execution of the job
Batch system
Opposite of interactive
The user’s program is batched together with programs from other
users and submitted by a computer operator
After the program is completed results are printed out for the
user
Problems:
Scheduling
Sign-up sheets were used to reserve processor time
This could result in wasted computer idle time if the user finished
early
If problems occurred the user could be forced to stop before
resolving the problem
Setup time
A single program could involve
Loading the compiler plus the source program into memory
Saving the compiled program
Loading and linking together the object program and common
functions
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Interrupt
Processing
Device
Drivers
Monitor
Job
Sequencing
Control Language
Interpreter
Boundary
User
Program
Area
Example:
$JOB
$FTN
**Each FORTRAN instruction and each item of
... Some Fortran instructions data is on a separate punched card or a separate record on
tape. In addition to FORTRAN and data lines, the job
$LOAD includes job control instructions, which are
$RUN denoted by the beginning “$”.
Timer Interrupts
Used to prevent a job from Gives the OS more flexibility
monopolizing the system in relinquishing control to
If the timer expires an and regaining control from
interrupt occurs and control user programs
returns to monitor
Time
(a) Uniprogramming
Uniprogramming Multiprogramming
Processor use 20% 40%
Memory use 33% 67%
Disk use 33% 67%
Printer use 33% 67%
Elapsed time 30 min 15 min
Throughput rate 6 jobs/hr 12 jobs/hr
Mean response time 18 min 10 min
CPU CPU
0% 0%
100% 100%
Memory Memory
0% 0%
100% 100%
Disk Disk
0% 0%
100% 100%
Terminal Terminal
0% 0%
100% 100%
Printer Printer
0% 0%
0 5 10 15
time
minutes
time
(a) Uniprogramming (b) Multiprogramming
Example:
If there are n users actively requesting service at one time, each
user will only see on the average 1/n of the effective computer
speed
Medium-term scheduling The decision to add to the number of processes that are
partially or fully in main memory
Medium-Term Short-Term
Part of the swapping
Also known as the
function
dispatcher
Swapping-in decision is
Executes frequently and
based on the need to manage
makes the fine-grained
the degree of
decision of which job to
multiprogramming
execute next
Swapping-in decision will
consider the memory
requirements of the
swapped-out processes
Event
Occurs Event
Wait
Blocked
State
Priority
Program counter
Memory pointers
Context data
I/O status
information
Accounting
information
A A A
"Running" "Waiting" "Waiting"
In
control
B B B
"Ready" "Ready" "Running"
In
control
Pass Control
to Process
I/O 1
Occurs
I/O 1 Queue
I/O 2
Occurs
I/O 2 Queue
I/O n
Occurs
I/O n Queue
Disk storage
Main
memory
Intermediate
queue Operating
system
Completed jobs
Long-term
and user sessions
queue
(b) Swapping
2M
8M 4M
6M
8M
8M
8M
8M
8M
12 M
8M
8M
16 M
8M
36M
Process 3 18M
Logical address 22M
- expressed as a location relative
to the beginning of the program 4M
6M
Process 4 8M Process 4 8M Process 4 8M
14M
6M 6M 6M
4M 4M 4M 4M
Page 1
Process A 13 Process A 13
of A
Page 0 Page 0
Page 1 Page 1 Page 2
14 14
Page 2 Page 2 of A
Page 3 Page 3
Page 3
15 15
of A
In In
16 16
use use
Free frame list Free frame list
13 In 20 In
17 17
14 use use
15 Process A
page table Page 0
18 18 18
of A
20 18
In 13 In
19 19
use use
14
15
20 20
Page 1
13
of A
16
18
17
13
14 Page 0
18
of A
15
Process A
Page Table
Principle of locality
When working with a large process execution may be confined to a small section of a
program (subroutine)
It is better use of memory to load in just a few pages
If the program references data or branches to an instruction on a page not in main
memory, a page fault is triggered which tells the OS to bring in the desired page
Advantages:
More processes can be maintained in memory
Time is saved because unused pages are not swapped in and out of memory
Disadvantages:
When one page is brought in, another page must be thrown out (page replacement)
If a page is thrown out just before it is about to be used the OS will have to go get the
page again
Thrashing
When the processor spends most of its time swapping pages rather than
executing instructions
Page 1
13
of A
16
18
17
13
14 Page 0
18
of A
15
Process A
Page Table
2m – 1 Frame # Offset
m bits
Inverted page table Real address
(one entry for each
physical memory frame)
Yes
CPU activates
I/O hardware Update TLB
Page transferred
from disk to CPU generates
main memory physical address
Memory Yes
full?
No Perform page
replacement
Page tables
updated
Figure 8.18 Operation of Paging and Translation Lookaside Buffer (TLB) [FURH87]
Page # Offset
TLB
TLB miss
TLB
hit Cache Operation
Real Address
Main
Memory
Page Table
Value
An executing program may only access data segments for which its
clearance level is lower than or equal to the privilege level of the data
segment
31 22 21 12 11 0
31 24 23 22 20 19 16 15 14 13 12 11 8 7 0
D A Segment
Base 31...24 G / L V limit P DPL S Type Base 23...16
B L 19...16
31 12 11 9 7 6 5 4 3 2 1 0
P P P U R
Page frame address 31...12 AVL S 0 A CW S WP
D T
AVL — Available for systems programmer use PWT — Write through = reserved
P — Page size US — User/supervisor
A — Accessed RW — Read-write
PCD — Cache disable P — Present
(d) Page directory entry
31 12 11 9 7 6 5 4 3 2 1 0
P P U R
Page frame address 31...12 AVL D A C W S WP
D T
D — Dirty
(e) Page table entry
Base
Defines the starting address of the segment within the 4-GByte linear address space.
D/B bit
In a code segment, this is the D bit and indicates whether operands and addressing modes
are 16 or 32 bits.
Descriptor Privilege Level (DPL)
Specifies the privilege level of the segment referred to by this segment descriptor.
Granularity bit (G)
Indicates whether the Limit field is to be interpreted in units by one byte or 4 KBytes.
Limit
Defines the size of the segment. The processor interprets the limit field in one of two ways,
depending on the granularity bit: in units of one byte, up to a segment size limit of 1
MByte, or in units of 4 KBytes, up to a segment size limit of 4 GBytes.
S bit
Determines whether a given segment is a system segment or a code or data segment.
Segment Present bit (P)
Used for nonpaged systems. It indicates whether the segment is present in main memory.
For paged systems, this bit is always set to 1.
Type
Distinguishes between various kinds of segments and indicates the access attributes.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Table 8.5
x86 Memory Management Parameters (page 2 of 2)
Page Directory Entry and Page Table Entry
Accessed bit (A)
This bit is set to 1 by the processor in both levels of page tables when a read or write
operation to the corresponding page occurs.
Dirty bit (D)
This bit is set to 1 by the processor when a write operation to the corresponding page
occurs.
Page Frame Address
Provides the physical address of the page in memory if the present bit is set. Since page
frames are aligned on 4K boundaries, the bottom 12 bits are 0, and only the top 20 bits are
included in the entry. In a page directory, the address is that of a page table.
Page Cache Disable bit (PCD)
Indicates whether data from page may be cached.
Page Size bit (PS)
Indicates whether page size is 4 KByte or 4 MByte.
Page Write Through bit (PWT)
Indicates whether write-through or write-back caching policy will be used for data in the
corresponding page.
Present bit (P)
Indicates whether the page table or page is in main memory.
Read/Write bit (RW)
For user-level pages, indicates whether the page is read-only access or read/write access for
user-level programs.
User/Supervisor bit (US)
Indicates whether the page is available only to the operating system (supervisor level) or is
available to both operating system and applications (user level).
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
+ Paging
ARM
core Cache
Virtual and Cache
address write line fetch
buffer hardware
Domain
Collection of memory regions. Access control can be applied on the basis of domain.
Shared (S)
Determines whether the translation is for not-shared (0), or shared (1) memory.
SBZ
Should be zero.
The region can be privileged access only, reserved for use by the OS and not by
applications