Download L03_Processes

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

Berkeley Software Distribution wikipedia , lookup

Library (computing) wikipedia , lookup

Security-focused operating system wikipedia , lookup

RSTS/E wikipedia , lookup

Copland (operating system) wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

VS/9 wikipedia , lookup

CP/M wikipedia , lookup

Unix security wikipedia , lookup

Paging wikipedia , lookup

Burroughs MCP wikipedia , lookup

Spring (operating system) wikipedia , lookup

DNIX wikipedia , lookup

Distributed operating system wikipedia , lookup

Kernel (operating system) wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
Processes
Introduction to Operating Systems: Module 3
System Calls
 System
calls provide the interface between a running
program and the operating system
Generally available as assembly-language (trap) instructions
 Languages defined to replace assembly language for systems
programming allow system calls to be made directly

 Methods
used to pass parameters to the operating system
Pass parameters in registers
 Store the parameters in a table in memory, and the table address is
passed as a parameter in a register
 Push (store) the parameters onto the stack by the program, and
pop off the stack by operating system

System Design Goals
goals – operating system should be convenient
to use, easy to learn, reliable, safe, fair, and fast
 System goals – operating system should be easy to
design, implement, and maintain, as well as
flexible, reliable, error-free, and efficient
 User
 System
goals and user goals may conflict
 efficiency
vs. fairness
 easy vs. flexible
System Structure – Layered Approach
 The
operating system is divided into a number of
layers or levels, each built on top of lower layers.
The lowest layer is the hardware; the highest is the
user interface.
 Layers are selected such that each uses functions
and services of only lower-level layers.
An Operating System Layer
layer M
Functions
implemented
at layer M
layer M -1
Functions
hidden by
layer M
Functions
passed by
layer M
Monolithic vs. Microkernel OS
 Monolithic
 Every
thing resides in the kernel
 process
and memory management
 Interrupts, I/O, device drivers, file
systems
 Networking
 Other functions and system calls
 The
Process in a monolithic OS
Kernel is big
 Everything
is part of every
application's address space
BIG
OS KERNEL
Process mngmt
Memory mngmt
I/O
File systems
Networking
Interrupts
All system calls
Shared Libraries
App1 code
App1 data
Not used
App1 Stack
Monolithic vs. Microkernel OS
Client
File Server
Memory
Server
Microkernel
Microkernel
Microkernel
Client
Microkernel
Message from client to server
 Microkernel
The kernel contains code for the most basic OS services
 All other OS services are provided by separate processes
running in user space
 Can modify components while system is running, don’t need
to recompile to change a driver or other component
 kernel, drivers export function tables to each other so they can
interact

Mechanisms and Policies
 Mechanisms
determine how to do something,
policies decide what will be done
 The separation of policy from mechanism is a very
important principle: it allows maximum flexibility
if policy decisions are to be changed later
 Micro-kernel design supports this separation
 Easy
to replace system components
 Monolithic
design encourages combined
mechanism and policy at a low level
Unix System Structure
 The
UNIX OS consists
of two parts:
 Systems
programs
 The kernel
 Consists
of everything
below the system-call
interface and above the
physical hardware
 Provides the file system,
CPU scheduling, memory
management, and other
OS functions
Windows Architecture
 Interaction
among executive components similar to
a microkernel system
 But
not all components run as user level services
 Executive
components communicate by passing
messages through a component called the kernel
 Hardware abstraction layer (HAL) maps generic
hardware interaction to specific platforms. HAL
isolates the kernel from architecture-specific details.
Windows Architecture
What is a Process





A program in execution
A sequentially executing piece of code that runs on one processing
unit of the system
An asynchronous computational activity
(i.e., it proceeds at its own pace, independent of another process)
The locus of control of a program in execution
A process is:



an encapsulation of program, data, resources and a virtual processor
controlled and supported by the underlying OS kernel
Which can interact with other processes and I/O devices through the OS kernel
The System View of Processes
 Processes
are an abstraction
 The
computer hardware executes instruction
 Instructions are grouped into multiple programs in
execution by software constructs
 Processes
do not exist when the computer starts
 The
instructions initially run set up the data structures
needed to implement the process abstraction
 The operating system is responsible more maintaining
the data structures that implement the process model
 The
OS needs a system that supports exceptions to do this
In the Beginning
 Hardware
defines a location from which the initial
instruction is fetched after system start-up
 This
bootstrap program loads the operating system code
and initializes operating system data
 Then
“real” processes can be created
 Though
the process abstraction is not yet defined when
it runs, the bootstrap program can be viewed as the
initial process
Address Space
 In
the process abstraction, an address space is more
than just memory
 Inter-process
communication objects
 Files
 Other
 Any
resources
entity which can be referenced by a process is
part of its address space
Process-OS interaction
Inter-process
Communication
•Program (text)
•Data (global variables)
•Stack (temporary data)
•Heap (dynamic memory)
File & I/O
Operations
System Calls
OS/Kernel
The operating system can handle all interaction between a process
and other system entities; each communication requires a system call
Process-OS interaction
Inter-process
Communication
•Program (text)
•Data (global variables)
•Stack (temporary data)
•Heap (dynamic memory)
File & I/O
Operations
System Calls
OS/Kernel
The operating system can set up communication channels between a
process and other system entities; once the channel is established,
further interaction does not require a system call
A UNIX Process
Object instructions
a.out
Static variables
Temporary
variables
Data
Program
Text
Stack
Process Status
Resources
Files
Abstract Machine Environment
Listing unix processes




list processes (Solaris 2):
ps — my processes, little detail
ps -l — my processes, more detail
ps -al — all processes, more detail
miller.cs: ps -l
F
UID
PID
8
1004
16628
8
1004
16780
8
1004
16884
PPID
16626
16628
16882
%C
0
3
0
PRI
58
58
58
NI
20
20
20
SZ
1724
1264
1724
RSS
1200
724
1200
WCHAN
???
???
???
S
S
S
S
TT
pts/103
pts/103
pts/108
TIME
0:00
0:03
0:00
COMMAND
-csh
find /
-csh
Process states
create
dispatch
activate
ready
inactive
running
pre-empt block
terminated
suspend
wakeup
terminate
waiting