Download Implementing Processes, Threads, and Resources

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Plan 9 from Bell Labs wikipedia , lookup

Mobile operating system wikipedia , lookup

Library (computing) wikipedia , lookup

Copland (operating system) wikipedia , lookup

RSTS/E wikipedia , lookup

Security-focused operating system wikipedia , lookup

DNIX wikipedia , lookup

Burroughs MCP wikipedia , lookup

VS/9 wikipedia , lookup

Spring (operating system) wikipedia , lookup

CP/M wikipedia , lookup

Distributed operating system wikipedia , lookup

Unix security wikipedia , lookup

Paging wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
Slide 3-1
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-2
Operating System
Organization
Copyright © 2004 Pearson Education, Inc.
3
Operating Systems: A Modern Perspective, Chapter 3
Operating System Structures
• OS Design Constraints
• OS Basic Functions
• OS Structures
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-3
Purpose of an OS
Coordinate Use
of the Abstractions
Processes
The Abstractions
Create the Abstractions
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-4
OS Requirements
• Provide resource abstractions
– Process abstraction of CPU/memory use
• Address space
• Thread abstraction of CPU within address space
– Resource abstraction
• “Anything a process can request that can block the
process if it is unavailable”
• NT uses “object abstraction” to reference resources
– File abstraction of secondary storage use
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-5
Slide 3-6
DOS -- Resource Abstraction Only
Program
Program
Libraries
Program
OS Services
ROM Routines
Processor(s)
Copyright © 2004 Pearson Education, Inc.
Main Memory
Operating Systems: A Modern Perspective, Chapter 3
Devices
Slide 3-7
OS Requirements (cont)
• Provide resource abstractions
• Manage resource sharing
–
–
–
–
Time/space-multiplexing
Exclusive use of a resource
Isolation
Managed sharing
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-8
Abstraction & Sharing
Process
Program
State
Process
Program
State
Process
Program
State
Libraries
OS Services
• Abstraction
• Manage sharing
Processor(s)
Copyright © 2004 Pearson Education, Inc.
Main Memory
Operating Systems: A Modern Perspective, Chapter 3
ROM Routines
Devices
Slide 3-9
OS Design Constraints
•
•
•
•
•
•
Performance
Protection and security
Correctness
Maintainability
Commercial factors
Standards and open systems
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-10
Performance
• The OS is an overhead function  should
not use too much of machine’s resources
• Minimum functionality is to implement
abstractions
• Additional function must be traded off
against performance
– DOS: one process
– UNIX: low level file system
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-11
Protection & Security
• Multiprogramming  resource sharing
• Therefore, need software-controlled
resource isolation
• Security policy: Sharing strategy chosen by
computer’s owner
• Protection mechanism: Tool to implement a
family of security policies
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-12
Correctness & Maintainability
• Security depends on correct operation of
software  trusted vs untrusted software
• Maintainability relates to ability of software
to be changed
• If either is sufficiently important, can limit
the function of the OS
– Guiding a manned spaceship
– Managing a nuclear reactor
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-13
OS Basic Functions
•
•
•
•
Device management
Process & resource management
Memory Management
File Management
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-14
Device Management
Device-Independent
Part
Device-Dependent
Part
Device-Dependent
Part
Device
Device
Copyright © 2004 Pearson Education, Inc.
Device-Dependent
Part
…
Operating Systems: A Modern Perspective, Chapter 3
Device
Slide 3-15
Device Management
• OS Manages the allocation, sharing and isolation
of I/O devices (disks, tapes, terminals, etc.)
• Most Operating Systems treat all devices in the
same general manner
– UNIX treats them all like files
• Chapters 4 & 5 discuss Device Management
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Process, Thread, and Resource
Management
Thread
Abstraction
Process
Abstraction
Multiprogramming
Generic
Resource
Manager
Other
Primary
Memory
…
Processor
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Abstract
Resources
Slide 3-16
Slide 3-17
Process & Resource
Management
• A process is the basic unit of computation
• Resources are the elements needed by a
process so that it can execute
– CPU, Memory, I/O devices, data etc.
• OS provides a set of process management
mechanisms: for process creation ,
blocking, resumption, termination ,etc
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-18
Process & Resource
Management
• OS manages computer resources so that
multiple processes can execute
simultaneously
– CPU scheduling
– resource allocation, sharing & process
synchronization
• Chapters 6 - 10
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-19
Memory Management
Isolation &
Sharing
Process
Manager
Block
Allocation
Virtual
Memory
Primary
Memory
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Storage
Devices
Slide 3-20
Memory Management
• Allocation and use of the primary memory
resource
– memory allocation among competing processes
– enforce memory isolation and sharing
• Most modern OS support virtual memory.
– Virtual memory allows processes to access data in
secondary storage as if it were in main memory.
• Chapters 11&12
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-21
File Management
• Information that need to be saved
"permanently" must be stored in a secondary
storage device e.g. a disk, tape, etc.
• Files are an abstraction of secondary storage
devices
• File manager is responsible for
– managing the file system: file & directory
creation and manipulation
– mapping files into physical storage devices
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-22
Exclusive Access to a Resource
Processor
Process A
Process B
A’s Protected
Object
Supervisor
Program
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-23
Processor Modes
• Mode bit: Supervisor or User mode
• Supervisor mode
– Can execute all machine instructions
– Can reference all memory locations
• User mode
– Can only execute a subset of instructions
– Can only reference a subset of memory
locations
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-24
Supervisor and User Memory
User
Process
User
Space
Supervisor
Process
Supervisor
Space
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-25
Kernels
• The part of the OS critical to correct
operation (trusted software)
• Executes in supervisor mode
• The trap instruction is used to switch from
user to supervisor mode, entering the OS
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-26
Procedure Call and Message Passing
Operating Systems
send(…, A, …);
receive(…, B, …);
call(…);
trap
send/receive
return;
Copyright © 2004 Pearson Education, Inc.
receive(…A, …);
…
send(…, B, …);
Operating Systems: A Modern Perspective, Chapter 3
System Call Using the trap Instruction
Slide 3-27
…
fork();
…
Trap Table
fork() {
…
trap
N_SYS_FORK()
…
}
Kernel
sys_fork()
sys_fork() {
/* system function */
…
return;
}
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-28
A Thread Performing a System Call
User Space
Kernel Space
Thread
fork();
sys_fork() {
}
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-29
Basic Operating System
Organization
File
Manager
Process, Thread &
Resource Manager
Processor(s)
Copyright © 2004 Pearson Education, Inc.
Memory
Manager
Device
Manager
Main Memory
Devices
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-30
OS Structures-Simple Approach
• MS-DOS - written to provide the most
functionality in the least space
– not divided into modules
– Although MS-DOS has some structures, its
interfaces and levels of functionality are not
well separated.
• application programs are able to access BIOS
routines directly (bypassing DOS).
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-31
OS Structures--UNIX
• UNIX -- modular
• UNIX consists of two separate parts:
– System programs (Shells and commands,
compilers and interpreters, system libraries)
– The kernel: part of OS that is most critical to
its correct operation (trusted)
• provides CPU scheduling, memory management,
file management, and other operating system
functions.
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-32
The UNIX Architecture
Interactive User
Application
…
Programs
OS System Call Interface
Commands
Device Driver
Device Driver
…
Device Driver
Copyright © 2004 Pearson Education, Inc.
Driver Interface
Libraries
Trap Table
Monolithic Kernel Module
•Process Management
•Memory Management
•File Management
•Device Mgmt Infrastructure
Operating Systems: A Modern Perspective, Chapter 3
Slide 3-33
Microkernel Organization
Process
Process
Process
Libraries
User
Supervisor
Server
Server
Server
Device Drivers
Microkernel
Processor(s)
Copyright © 2004 Pearson Education, Inc.
Main Memory
Operating Systems: A Modern Perspective, Chapter 3
Devices
Linux
Slide 3-34
• A contemporary, open source implementation of
UNIX, introduced in 1991 (Linus Trovalds)
• A universal system: timesharing OS, personal
computer and workstations OS, embedded systems
OS, SCC (small communicating computers) OS,
network OS
• Today’s Linux distribution includes the OS and a
spectrum of supplementary tools, written by many
different contributors
• Originally implemented for Intel
80386/80486/80586 (x86 or i386), now for
DEC/Compaq/HP Alpha, Sun Sparc, Motorola
68K, MIPS, Power PC
• Monolithic kernel, supports dynamically
installable modules
Copyright © 2004 Pearson Education, Inc.
Operating Systems: A Modern Perspective, Chapter 3
Windows NT Organization
T
Process
T
T
T
Process
Slide 3-35
Process
T
T
T
T
Process Management
Memory Management
File Management
Subsystem
Subsystem
Device Mgmt Infrastructure
T
Libraries
Subsystem
User
Supervisor
NT Executive
NT Kernel
Hardware Abstraction Layer
Processor(s)
Copyright © 2004 Pearson Education, Inc.
Main Memory
Operating Systems: A Modern Perspective, Chapter 3
I/O Subsystem
Devices
Slide 3-36
Monitoring the Kernel
T
Process
Task
Manager
T
T
T
Process
Process
T
T
T
T
T
pview
Libraries
pstat
Subsystem
Subsystem
Subsystem
User
Supervisor
NT Executive
NT Kernel
Hardware Abstraction Layer
Processor(s)
Copyright © 2004 Pearson Education, Inc.
Main Memory
Operating Systems: A Modern Perspective, Chapter 3
I/O Subsystem
Devices