0% found this document useful (0 votes)
71 views

Slot14 15 CH08 OperatingSystemSupport 43 Slides

The document summarizes key concepts related to operating system support. It discusses: 1) The interfaces between applications, operating systems, and hardware including application programming interfaces (APIs) and instruction set architectures (ISAs). 2) Types of operating systems including interactive systems, batch systems, and time-sharing systems. 3) How operating systems act as resource managers by scheduling processes using long-term, medium-term, and short-term scheduling techniques. Processes are stored in process tables and move between ready, running, and blocked states.

Uploaded by

tuan luu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

Slot14 15 CH08 OperatingSystemSupport 43 Slides

The document summarizes key concepts related to operating system support. It discusses: 1) The interfaces between applications, operating systems, and hardware including application programming interfaces (APIs) and instruction set architectures (ISAs). 2) Types of operating systems including interactive systems, batch systems, and time-sharing systems. 3) How operating systems act as resource managers by scheduling processes using long-term, medium-term, and short-term scheduling techniques. Processes are stored in process tables and move between ready, running, and blocked states.

Uploaded by

tuan luu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

+

Chapter 8 Operating System


Support
William Stallings, Computer Organization and Architecture, 9 th Edition
The Operating System as
User/Computer Interface
+ Interfaces
Key interfaces in a typical computer system:

Application
Instruction Set Application Binary
Programming
Architecture (ISA) Interface (ABI)
Interface (API)

Defines the machine Gives a program


Defines a standard for
language instructions access to the
binary portability
that a computer can hardware resources
across programs
follow and services available
in a system through
the user ISA
supplemented with
Defines the system high-level language
call interface to the (HLL) library calls
Boundary between
hardware and software operating system and
the hardware
resources and services
available in a system Using an API enables
through the user ISA application software
to be ported easily to
other systems that
support the same API
The OS as Resource Manager
+
Types of Operating Systems

 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
+
Simple Batch
System:

Memory
Layout
for a
Resident Monitor
+
From the View of the Processor . . .

 Processorexecutes instructions from the portion of main memory


containing the monitor
 These instructions cause the next job to be read in another portion of
main memory
 The processor executes the instruction in the user’s program until it
encounters an ending or error condition
 Either event causes the processor to fetch its next instruction from the
monitor program
 The monitor handles setup and scheduling
 A batch of jobs is queued up and executed as rapidly as possible with no
idle time
 Job control language (JCL)
 Specialtype of programming language used to provide instructions to
the monitor
+
From the View of the Processor . . .
 Example:
 $JOB **Each FORTRAN instruction and
each item of data is on a separate
 $FTN punched card or a separate record on
 ... Some Fortran instructions tape. In addition to FORTRAN and
data lines, the job includes job control
 $LOAD instructions, which are
 $RUN denoted by the beginning “$”.
 ... Some data
 $END

 Monitor, or batch OS, is simply a computer program


 It relies on the ability of the processor to fetch instructions from
various portions of main memory in order to seize (nắm lấy) and
relinquish (từ bỏ) control alternately
+ Desirable Hardware Features
 Memory protection  Privileged instructions
 User program must not alter the  Lệnh đặc biệt, nhạy cảm
memory area containing the monitor
 Can only be executed by the monitor
 The processor hardware should detect
an error and transfer control to the  If the processor encounters such an
monitor instruction while executing a user
program an error interrupt occurs
 The monitor aborts the job, prints an
error message, and loads the next job  I/O instructions are privileged so the
monitor retains control of all I/O devices

 Timer  Interrupts
 Used to prevent a job from  Gives the OS more flexibility in
monopolizing (độc chiếm) the relinquishing control to and regaining
system control from user programs
 If the timer expires an interrupt
occurs and control returns to
monitor
+

Multiprogramming
Example
+ Time Sharing Systems

 Used when the user interacts directly with the computer


 Processor’s time is shared among multiple users
 Multiple users simultaneously access the system through
terminals, with the OS interleaving the execution of each
user program in a short burst or quantum (time slice, time
slot) of computation
 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
Batch
Multiprogramming
versus
Time Sharing

+
+ 8.2- Scheduling

 The key to multiprogramming


 Four types are typically involved:

Program: executable file stored in external memory


Process: program in execution
+ Scheduling….
Memory

P0’s mem.
Which of
Process 0
them will
run ? Process 1
Short-term Process 2 P2’s mem.
Scheduling
Process 3
(current
processes) P4’s mem.

Long-term Process
Accept ?
Scheduling Table P1’s mem.
(waiting programs)
Where will
New process be used to
load it ?

Each element of the process table Medium-term


Scheduling (blocked
is called as Process Control Block
processes)
Long Term Scheduling
In some systems a
newly created
process begins in a
Determines which Once submitted, a
swapped-out
programs are job becomes a
condition, in which
submitted for process for the short
case it is added to a
processing term scheduler
queue for the
medium-term
scheduler
Swapped-out process: Process stored in RAM must be write
to disk. It shields it’s memory to swapped-in process.

Time-sharing system
Batch system
• A process request is generated when a
• Newly submitted jobs
user attempts to connect to the system
• OS will accept all authorized comers are routed to disk and
held in a batch queue
until the system is saturated • The long-term
• At that point a connection request is
scheduler creates
met with a message indicating that the processes from the
system is full and to try again later queue when it can
+
Medium-Term Scheduling
and Short-Term Scheduling

Medium-Term Short-Term
Part of the swapping function  Also known as the dispatcher
Swapping-in decision is based (trình điều phối)
on the need to manage the degree  Executes frequently and makes
of multiprogramming
the fine-grained decision of
Swapping-in decision will which job to execute next
consider the memory
requirements of the swapped-out
processes
Short-Term Scheduling
Five State Process Model

Interrupt
from IO
IO operation

CPU can be allocated


to another process
+ Index of instruction
which will be
fetched when the
Process Control process re-executes.
Block (PCB)
Values of registers at
the time the process
is blocked
What are metadata of a
process?
Scheduling Example

2. Time out
Calls a service
Key Elements of O/S
Process Scheduling
8.3- Memory Management

 Memory Management
 Swapping
 Partioning
 Paging
 Virtual Memory
 Translation Lookaside Buffer
 Segmentation
Memory Manager is a part of OS which bears
responsibility to manage computer memory at the system
level and some above techniques can be applied.
+Memory
Management:
Swapping

Why?
Memory has larger size 
Processes request more and more
memory, more processes need to
run  Memory is not enough to
supply  A selected process
must be swapped out to disk in
order to load new process
(SWAP)
+
Memory Management

Partitioning
Smaller process needs
smaller memory 
Unequal-size partition
is better.
Effect of Dynamic Partitioning
To enable loading a
process to any position of
memory, program
addresses must be
expressed as logical
addresses
Logical address
- expressed as a location
relative to the beginning of the
program (offset)

Physical address
- an actual location in main
memory

Base address
- current starting location
of the process
+
Memory Management
Paging

At a time, only one instruction of


the current process executes 
Only necessary part of each
process is loaded  Many
processes can be loaded.

Programs are divided into small


fixed chunk (ex. 4KB). At a time,
only some pages of each process
are loaded to memory (frames)

Memory is divided also to frames

Frame size= Page size Loading 4 frames of the process A


+ How to determine physical address
from a logical address?
Paging

Logical and
Physical
Addresses

0
Each program 1
address is expressed 2
as a logical address 3
which is a pair of
(page, offset)
+
Virtual Memory: Demand Paging

 Each page of a process is brought in only when it


is needed
 Principle of locality
 When working with a large process execution may be confined
(limited) 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
+
Virtual Memory: Demand Paging
 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 (đánh bại- hệ thống trì trệ)
 When the processor spends most of its time swapping pages rather
than executing instructions
+
Paging:
Inverted
Page
Table
Structure
A large table is used to
store all pages of all
procsses

Hash function allows determine the position of a table in which data is stored.
Example: h(n) = n modulo k ( n%k)
If h(n2) = position storing n1, n2 will be stored in the lower position (overflow area) and
they are marked in the field chain.
+
Paging:
Operation of Paging
TLB
and Translation TLB hit
miss
Lookaside Buffer
(TLB)

TLB is an hardware
including some registers. A
part of page table is copied
to them in order to increase
performance of translating
virtual addresses to physical
addresses.
TLB and Cache Operation
+ Segmentation
 Program is divided in to segments (data, code,
stack, heap segments)
 Usually visible to the programmer
 Advantages:
 Provided as a convenience for
 Simplifies the handling of
organizing programs and data and as
growing data structures
a means for associating privilege and
protection attributes with instructions  Allows programs to be
and data altered and recompiled
independently without
 Allows the programmer to view requiring that an entire set of
memory as consisting of multiple programs be re-linked and
address spaces or segments re-loaded
 A segment can be shared
 A segment can be divided into some among processes
pages.
 A segment can be added
individual protection

You might also like