1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Operating system principles - Chapter 3: Process description and control

56 89 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 56
Dung lượng 288,03 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Chapter 3 - Process description and control. This chapter refers to virtual memory. Much of the time, we can ignore this concept in dealing with processes, but at certain points in the discussion, virtual memory considerations are pertinent.

Trang 1

Chapter 3 Process Description and Control

– What is a process?

– 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

Trang 2

Requirements of an Operating System

• Fundamental Task: Process Management

• The Operating System must

– Interleave the execution of multiple processes – Allocate resources to processes

– Protect the resources of each process from

other processes

– Enable processes to share and exchange

information

Trang 3

• A unit of activity characterized by the

execution of a sequence of instructions, a current state, and an associated set of

system resources

Trang 4

Process Elements

• A process is comprised of:

– Program code (possibly shared)

– A set of data associated with the code

– A number of attributes describing the state of the process

Trang 5

Process Elements

• While the process is running, it has a

number of attributes including

Trang 6

Trace of the Process

• The behavior of an individual process is

shown by listing the sequence of

instructions that are executed

• This list is called a Trace

• Dispatcher is a small program which

switches the processor from one process

to another

Trang 7

Process Execution

• Consider three processes being executed

• All are in memory (plus the dispatcher)

Trang 8

Trace from the Process point of view:

The 4 th instruction of Process B invokes an I/O operation.

Trang 9

Trace from Processor’s

point of view

Timeout I/O Timeout

Time slice: 6 instruction cycles

Trang 10

– What is a process?

– 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

Trang 11

Two-State Process Model

• To control processes, we need to describe their

behavior

• Process may be in one of two states

– Running

– Not-running

Trang 12

Queuing Diagram

Etc … processes moved by the dispatcher of the OS to the CPU then back

to the queue until the task is competed

Processes that are not running must be kept in

some sort of queue, waiting their turn to

execute

Trang 13

Process Birth and Death

Common Reasons

New batch job Normal Completion

Interactive Login Memory unavailable

Created by OS to

provide a service Protection error

Spawned by existing

process Operator or OS Intervention

See tables 3.1 and 3.2 for more

Trang 14

Process Creation

• The OS builds a data structure to manage the

process

• Traditionally, the OS creates all processes

– But it can be useful to let a running process create

another, e.g., a server process may generate a new

process for each request

• This action is called process spawning

– Parent Process is the original, creating process

– Child Process is the new process

Trang 15

Process Termination

• There must be some way that a process

can indicate completion.

• This indication may be:

– A HALT instruction for termination in a batch

Trang 16

Five-State Process Model

Processes may be blocked (e.g., waiting

for an I/O operation)

Trang 17

Using Two Queues

Trang 18

Multiple Blocked Queues

Trang 19

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

Trang 20

One Suspend State

Trang 21

Two Suspend States

When the event of a suspended (and blocked) process occurs, the process is not blocked and is

potentially available for execution.

Trang 22

Process Suspension

Common Reasons

bring in a process that is ready to execute.

Interactive User

Request

e.g debugging or in connection with the use of a resource.

accounting or system monitoring process) and may

be suspended while waiting for the next time.

Parent Process

Request

A parent process may wish to suspend execution of

a descendent to examine or modify the suspended process, or to coordinate the activity of various descendants.

Trang 23

– What is a process?

– 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

Trang 24

Processes and Resources

OS can be thought of an entity

that manages the use of system

resources by processes.

Trang 25

Operating System Control Structures

• For the OS 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

Trang 26

OS Control Tables

Trang 27

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

Trang 28

I/O Tables

• Used by the OS to manage the I/O

devices and channels of the computer.

• The OS needs to know

– Whether the I/O device is available or

assigned

– The status of I/O operation

– The location in main memory being used as

the source or destination of the I/O transfer

Trang 29

• Sometimes this information is maintained

by a file management system

Trang 30

Process Tables

• To manage processes, the OS needs to

know details of the processes

– Current state

– Process ID

– Location in memory

– etc

• Process image is the collection of

program, data, stack, and attributes

Trang 31

Process Attributes

• The attributes are stored in

a data structure called a

process control block

(PCB)

• It contains sufficient

information so that it is

possible to interrupt a

running process and later

resume its execution.

Trang 32

Process Attributes

• We can group the PCB information into

three general categories:

– Process identification

– Processor state information

– Process control information

Trang 33

Process Identification

• Each process is assigned a unique

numeric identifier.

• Many of the other tables controlled by the

OS may use process identifiers to

cross-reference process tables

Trang 34

– Program status word (PSW) contains

condition codes and other status information

Trang 35

Process Control

Information

• This is the additional information needed

by the OS to control and coordinate the

various active processes.

– Process state, priority, identity of the waiting

event etc

– See table 3.5 for scope of information

Trang 36

Structure of Process

Images in Virtual Memory

Trang 37

Role of the Process Control Block

• PCB is the most important data structure

in an OS

– OS needs information about a process which

is stored in PCB

– Most OS modules, such as scheduling,

resource allocation, and interrupt processing

read and/or modify PCBs

– The set of PCBs defines the state of the OS

Trang 38

– What is a process?

– 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

Trang 39

Modes of Execution

• Most processors support at least two

modes of execution to protect OS from

interference by user programs

Trang 40

Process Creation

• Once the OS decides to create a new

process, it:

– Assigns a unique process identifier

– Allocates space for the process

– Initializes process control block

– Sets up appropriate linkages

– Creates or expands other data structures

Trang 41

Switching Processes

• Several design issues are raised regarding process switching

– What events trigger a process switch?

– What must the OS do to the various data

structures under its control to achieve a

process switch?

Trang 42

When to switch processes

Interrupt External to the execution of

the current instruction Reaction to an asynchronousexternal event

Trap Associated with the execution

of the current instruction

Handling of an error or an exception condition

Supervisor call Explicit request Call to an operating system

function

A process switch may occur any time that OS has gained control from the currently running process Possible events giving OS control are:

Trang 43

Change of Process State …

• The steps in a process switch are:

1 Save context of processor including program

counter and other registers

2 Update the process control block of the

process that is currently in the Running state

3 Move process control block to appropriate

queue – ready; blocked; ready/suspend

Trang 44

Change of Process State cont…

4 Select another process for execution

5 Update the process control block of the

Trang 45

Mode Switching

• The occurrence of an interrupt does not

necessarily mean a process switch.

• It is possible that, after the interrupt

handler has executed, the currently

running process will resume execution.

• In that case, only need to save / restore

the processor state information in

Trang 46

Is the OS a Process?

• If the OS is just a collection of programs

and if it is executed by the processor just

like any other program, is the OS a

process?

• If so, how is it controlled?

– Who (what) controls it?

• These questions have inspired a number

of design approaches

Trang 47

Non-process Kernel

• Execute kernel outside of any process

– OS has its own region of memory and system stack

• 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

Trang 48

– No need for Process Switch to

run OS routine, only Mode Switch

Trang 49

Process-based Operating System

• Process-based operating system

– Implement the OS as a collection of system

process

Trang 50

Security Issues

• An OS associates a set of privileges with

each process.

– These privileges dictate what resources the

process may access

– Highest level being administrator, supervisor,

or root access

• A key security issue in the design of any

OS is to prevent anything (user or

process) from gaining unauthorized

privileges on the system

Trang 51

System access threats

• Intruders (hackers, crackers)

– gain access to a system

– acquire protected information

Trang 52

System access threats

• Malicious software (malware)

– destroy files and data in main memory

– bypass controls to gain privileged access

– provide a means for intruders to bypass

access control

– parasitic (to a host program) e.g., viruses

– self-contained (independent), e.g., worms

Trang 53

Countermeasures:

Intrusion Detection

• Intrusion detection systems (IDS) monitors and analyzes system events for

suspicious activity to detect human

intruder and malicious software behaviour.

• IDS typically comprise

– Sensors for collecting data, e.g., log files

– Analyzers for determining if an intrusion has

occurred

– User Interface for viewing output and

Trang 54

Countermeasures:

Authentication

• Two Stages:

– Identification (provide a claimed identity)

– Verification (establish validity of the claim)

• Four Factors:

– Something the individual knows

– Something the individual possesses

– Something the individual is (static biometrics)

– Something the individual does (dynamic

Trang 55

Countermeasures:

Access Control

• A policy governing access to resources

• A security administrator maintains an

authorization database that specifies what type of access to which resources is

allowed for which users

– The access control function consults this to

determine whether to grant access

Trang 56

Countermeasures:

Firewalls

• Firewalls protect a local system from

network-based security threats while at

the same time afford access to the

outside world.

• Traditionally, a firewall is a dedicated

computer that:

– interfaces with computers outside a network

– has special security precautions built into it to protect sensitive files on computers within

the network

Ngày đăng: 30/01/2020, 05:34

TỪ KHÓA LIÊN QUAN