Sie sind auf Seite 1von 17

Operating Systems:

Internals and Design Principles, 6/E Roadmap


William Stallings
– How are processes represented and
controlled by the OS.
– Process states which characterize the
Chapter 3 behaviour of processes.
Process Description and Control – Data structures used to manage processes.
– Ways in which the OS uses these data
structures to control process execution.
– Discuss process management in UNIX SVR4.

Dave Bremer
Otago Polytechnic, N.Z.
©2008, Prentice Hall

Requirements of an
Concepts
Operating System
• Fundamental Task: Process Management • From earlier chapters we saw:
– Computer platforms consists of a collection of
• The Operating System must hardware resources
– Interleave the execution of multiple processes
– Allocate resources to processes, and protect – Computer applications are developed to
the resources of each process from other perform some task
processes,
– It is inefficient for applications to be written
– Enable processes to share and exchange directly for a given hardware platform
information,
– Enable synchronization among processes.
The OS Manages
Concepts cont…
Execution of Applications
– OS provides an interface for applications to • Resources are made available to multiple
use
applications
– OS provides a representation of resources • The processor is switched among multiple
that can be requested and accessed by application
application
• The processor and I/O devices can be
used efficiently

What is a “process”? Process Elements


• A program in execution • A process is comprised of:
• An instance of a program running on a – Program code (possibly shared)
computer – A set of data
• The entity that can be assigned to and – A number of attributes describing the state of
executed on a processor the process
• A unit of activity characterized by the
execution of a sequence of instructions, a
current state, and an associated set of
system instructions
Process Elements Process Control Block
• While the process is running it has a • Contains the process
number of elements including elements
– Identifier • Created and manage by
– State the operating system
– Priority • Allows support for
– Program counter
multiple processes
– Memory pointers
– Context data
– I/O status information
– Accounting information

Trace of the Process Process Execution


• The behavior of an individual process is • Consider three
shown by listing the sequence of processes being
instructions that are executed executed
• This list is called a Trace • All are in memory
• Dispatcher is a small program which (plus the dispatcher)
switches the processor from one process • Lets ignore virtual
to another memory for this.
Trace from the Trace from Processors
processes point of view: point of view
• Each process runs to completion

Timeout
I/O

Roadmap Two-State Process Model


– How are processes represented and • Process may be in one of two states
controlled by the OS. – Running
– Not-running
– Process states which characterize the
behaviour of processes.
– Data structures used to manage processes.
– Ways in which the OS uses these data
structures to control process execution.
– Discuss process management in UNIX SVR4.
Queuing Diagram Process Birth and Death
Creation Termination
New batch job Normal Completion
Interactive Login Memory unavailable
Created by OS to Protection error
provide a service
Etc … processes moved by the dispatcher of the OS to the CPU then back Spawned by existing Operator or OS
to the queue until the task is competed
process Intervention
See tables 3.1 and 3.2 for more

Process Creation Process Termination


• The OS builds a data structure to manage • There must be some way that a process
the process can indicate completion.
• Traditionally, the OS created all processes • This indication may be:
– But it can be useful to let a running process – A HALT instruction generating an interrupt
create another alert to the OS.
• This action is called process spawning – A user action (e.g. log off, quitting an
– Parent Process is the original, creating, application)
process – A fault or error
– Child Process is the new process – Parent process terminating
Five-State
Using Two Queues
Process Model

Multiple Blocked Queues Suspended Processes


• Processor is faster than I/O so all
processes could be waiting for I/O
– Swap these processes to disk to free up more
memory and use processor on more
processes
• Blocked state becomes suspend state
when swapped to disk
• Two new states
– Blocked/Suspend
– Ready/Suspend
One Suspend State Two Suspend States

Reason for Process


Roadmap
Suspension
Reason Comment
The OS needs to release sufficient main memory to
– How are processes represented and
Swapping
bring in a process that is ready to execute. controlled by the OS.
Other OS Reason OS suspects process of causing a problem.
– Process states which characterize the
Interactive User e.g. debugging or in connection with the use of a
Request resource. behaviour of processes.
Timing A process may be executed periodically (e.g., an – Data structures used to manage processes.
accounting or system monitoring process) and may
be suspended while waiting for the next time. – Ways in which the OS uses these data
Parent Process A parent process may wish to suspend execution of structures to control process execution.
Request a descendent to examine or modify the suspended
process, or to coordinate the activity of various – Discuss process management in UNIX SVR4.
descendants.
Table 3.3 Reasons for Process Suspension
Processes Operating System
and Resources Control Structures
• For the OS is to manage processes and
resources, it must have information about
the current status of each process and
resource.
• Tables are constructed for each entity the
operating system manages

OS Control Tables Memory Tables


• Memory tables are used to keep track of
both main and secondary memory.
• Must include this information:
– Allocation of main memory to processes
– Allocation of secondary memory to processes
– Protection attributes for access to shared
memory regions
– Information needed to manage virtual memory
I/O Tables File Tables
• Used by the OS to manage the I/O • These tables provide information about:
devices and channels of the computer. – Existence of files
• The OS needs to know – Location on secondary memory
– Whether the I/O device is available or – Current Status
assigned – other attributes.
– The status of I/O operation • Sometimes this information is maintained
– The location in main memory being used as by a file management system
the source or destination of the I/O transfer

Process Tables Process Attributes


• To manage processes the OS needs to
• We can group the process control block
know details of the processes
information into three general categories:
– Current state
– Process identification
– Process ID
– Processor state information
– Location in memory
– Process control information
– etc
• Process control block
– Process image is the collection of program.
Data, stack, and attributes
Processor State
Process Identification
Information
• Each process is assigned a unique • This consists of the contents of processor
numeric identifier. registers.
• Many of the other tables controlled by the – User-visible registers
OS may use process identifiers to cross- – Control and status registers
reference process tables – Stack pointers
• Program status word (PSW)
– contains status information
– Example: the EFLAGS register on Pentium
processors

Pentium II Process Control


EFLAGS Register Information
• This is the additional information needed
by the OS to control and coordinate the
various active processes.
– See table 3.5 for scope of information

Also see Table 3.6


Structure of Process Role of the
Images in Virtual Memory Process Control Block
• The most important data structure in an
OS
– It defines the state of the OS
• Process Control Block requires protection
– A faulty routine could cause damage to the
block destroying the OS’s ability to manage
the process
– Any design change to the block could affect
many modules of the OS

Roadmap Modes of Execution


– How are processes represented and • Most processors support at least two
controlled by the OS. modes of execution
– Process states which characterize the • User mode
behaviour of processes. – Less-privileged mode
– Data structures used to manage processes. – User programs typically execute in this mode
– Ways in which the OS uses these data • System mode
structures to control process execution. – More-privileged mode
– Discuss process management in UNIX SVR4. – Kernel of the operating system
Process Creation Switching Processes
• Once the OS decides to create a new • Several design issues are raised regarding
process it: process switching
– Assigns a unique process identifier – What events trigger a process switch?
– Allocates space for the process – We must distinguish between mode switching
– Initializes process control block and process switching.
– Sets up appropriate linkages – What must the OS do to the various data
– Creates or expand other data structures structures under its control to achieve a
process switch?

Change of
When to switch processes
A process switch may occur any time that the OS has gained control from the
Process State …
currently running process. Possible events giving OS control are: • The steps in a process switch are:
1. Save context of processor including program
Mechanism Cause Use counter and other registers
Interrupt External to the execution of Reaction to an asynchronous 2. Update the process control block of the
the current instruction external event
process that is currently in the Running state
Trap Associated with the execution Handling of an error or an 3. Move process control block to appropriate
of the current instruction exception condition queue – ready; blocked; ready/suspend
Supervisor call Explicit request Call to an operating system
function

Table 3.8 Mechanisms for Interrupting the Execution of a Process


Change of
Is the OS a Process?
Process State cont…
4. Select another process for execution • If the OS is just a collection of programs
5. Update the process control block of the and if it is executed by the processor just
process selected like any other program, is the OS a
6. Update memory-management data process?
structures • If so, how is it controlled?
7. Restore context of the selected process – Who (what) controls it?

Execution of the
Non-process Kernel
Operating System
• Execute kernel outside of any process
• The concept of process is considered to
apply only to user programs
– Operating system code is executed as a
separate entity that operates in privileged mode
Execution Within Process-based
User Processes Operating System
• Execution Within User • Process-based operating system
Processes – Implement the OS as a collection of system
– Operating system software within process
context of a user process
– No need for Process Switch to
run OS routine

Security Issues System access threats


• An OS associates a set of privileges with • Intruders
each process. – Masquerader (outsider)
– Highest level being administrator, supervisor, – Misfeasor (insider)
or root, access. – Clandestine user (outside or insider)
• A key security issue in the design of any • Malicious software (malware)
OS is to prevent anything (user or
process) from gaining unauthorized
privileges on the system
– Especially - from gaining root access.
Countermeasures: Countermeasures:
Intrusion Detection Authentication
• Intrusion detection systems are typically • Two Stages:
designed to detect human intruder and – Identification
malicious software behaviour. – Verification
• May be host or network based • Four Factors:
• Intrusion detection systems (IDS) typically – Something the individual knows
comprise – Something the individual possesses
– Sensors – Something the individual is (static biometrics)
– Analyzers – Something the individual does (dynamic
– User Interface biometrics)

Countermeasures: Countermeasures:
Access Control Firewalls
• A policy governing access to resources • Traditionally, a firewall is a dedicated
• A security administrator maintains an computer that:
authorization database – interfaces with computers outside a network
– The access control function consults this to – has special security precautions built into it to
determine whether to grant access. protect sensitive files on computers within the
network.
• An auditing function monitors and keeps a
record of user accesses to system
resources.
Roadmap Unix SVR4
System V Release 4

– How are processes represented and • Uses the model of fig3.15b where most of
controlled by the OS. the OS executes in the user process
– Process states which characterize the • System Processes - Kernel mode only
behaviour of processes.
• User Processes
– Data structures used to manage processes.
– User mode to execute user programs and
– Ways in which the OS uses these data utilities
structures to control process execution.
– Kernel mode to execute instructions that belong
– Discuss process management in UNIX SVR4. to the kernel.

UNIX Process State


UNIX Process States
Transition Diagram
A Unix Process Process Creation
• A process in UNIX is a set of data • Process creation is by means of the kernel
structures that provide the OS with all of system call,fork( ).
the information necessary to manage and • This causes the OS, in Kernel Mode, to:
dispatch processes. 1. Allocate a slot in the process table for the
• See Table 3.10 which organizes the new process.
elements into three parts: 2. Assign a unique process ID to the child
– user-level context, process.
– register context, and 3. Copy of process image of the parent, with
the exception of any shared memory.
– system-level context.

Process Creation
After Creation
cont…
4. Increment the counters for any files owned • After creating the process the Kernel can
by the parent, to reflect that an additional do one of the following, as part of the
process now also owns those files. dispatcher routine:
5. Assign the child process to the Ready to
– Stay in the parent process.
Run state.
– Transfer control to the child process
6. Returns the ID number of the child to the
parent process, and a 0 value to the child – Transfer control to another process.
process.

Das könnte Ihnen auch gefallen