0% found this document useful (0 votes)
11 views12 pages

Chap 03

Uploaded by

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

Chap 03

Uploaded by

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

Operating Systems:

Internals and Design Principles, 6/E


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

Dave Bremer
9/14/11 Otago Polytechnic, N.Z.
©2008, ice all

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,

– Enable processes to share and exchange It is inefficient for applications to be written
information, directly for a given hardware platform
– Enable synchronization among processes.

Concepts cont… The OS Manages


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:
• – Program code (possibly shared)
An instance of a program running on a
– A set of data
computer

• 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


• Contains the process
• While the process is running it has a
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


– • Process may be in one of two states
How are processes represented and
– Running
controlled by the OS.
– 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 – How are processes represented and
Swapping The OS needs to release sufficient main memory to
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 behaviour of processes.
Request resource.
– Data structures used to manage processes.
Timing A process may be executed periodically (e.g., an
accounting or system monitoring process) and may – Ways in which the OS uses these data
be suspended while waiting for the next time.
structures to control process execution.
Parent Process A parent process may wish to suspend execution of
a descendent to examine or modify the suspended – Discuss process management in UNIX SVR4.
Request
process, or to coordinate the activity of various
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
• – Location on secondary memory
The OS needs to know
– – Current Status
Whether the I/O device is available or
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
Process Identification Processor State
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
– Control and status registers
OS may use process identifiers to cross-
– Stack pointers
reference process tables
• 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
• Most processors support at least two
– How are processes represented and
controlled by the OS. modes of execution

– Process states which characterize the User mode
– Less-privileged mode
behaviour of processes.
– 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
process it: regarding 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.
– – What must the OS do to the various data
Sets up appropriate linkages
– Creates or expand other data structures structures under its control to achieve a
process switch?

When to switch processes Change of


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
3. Move process control block to appropriate
Trap Associated with the execution Handling of an error or an
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?
• If so, how is it controlled?
structures
– Who (what) controls it?
7. Restore context of the selected process

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 each • Intruders
process. – Masquerader (outsider)
– Highest level being administrator, supervisor, or root, – Misfeasor (insider)
access.
– Clandestine user (outside or insider)
• A key security issue in the design of any OS is
• Malicious software (malware)
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:
– interfaces with computers outside a network
authorization database
– – has special security precautions built into it to
The access control function consults this 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 the
controlled by the OS. 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 utilities
– Ways in which the OS uses these data – Kernel mode to execute instructions that belong
structures to control process execution. to the kernel.
– Discuss process management in UNIX SVR4.

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.
– 3. Copy of process image of the parent, with
register context, and

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
– Transfer control to another process.
parent process, and a 0 value to the child
process.

You might also like