Top Banner
Process Control Process Control Block (PCB) Process State Information Process Control Information Functions of an Operating-System Kernel Switch a Process Change of Process State Execution of the Operating System
30

Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Process Control

Process Control Block (PCB)Process State InformationProcess Control InformationFunctions of an Operating-System

KernelSwitch a ProcessChange of Process StateExecution of the Operating System

Page 2: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Operating System Control Structures

Schedules and dispatches processed for execution by the processor

Allocates resources to processes(Think about struct rlimt and getrlimit)

Responds to requests by user programs(Think about getopt)Tables are constructed for each entity

the operating system manages

Page 3: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Memory Tables

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

Page 4: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

I/O Tables

I/O device is available or assignedStatus of I/O operationLocation in main memory being used

as the source or destination of the I/O transfer

Page 5: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

File Tables

Existence of filesLocation on secondary memoryCurrent StatusAttributesSometimes this information is

maintained by a file-management system(Think about struct stat and stat( ) )

Page 6: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Process Table

Process image consists of program, data, stack, and attributes

Attributes process control block

( Think about Process ID and getpid( ) )(Think about Resource Limits and getrlimit( ) )

Page 7: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Process State Transition Diagram with Two Suspend States - Seven-State Process Model

New

AdmitAdmit Suspend

Dispatch

Time out

Ready,suspend

Ready

BlockedBlocked,suspend

EventOccurs

Activate

EventOccurs

Activate

Suspend

Running Exit

EventWait

Suspend

Page 8: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

UNIX Process State Transition Diagram (1)

returnto user

return

preempt

rescheduleprocess

sleep

exitinterrupt,

interrupt return

system call,interrupt

wakeup

swap out

wakeup

swap in

swap out

enoughmemory

not enough memory(swapping system only)

fork

Zombie

KernelRunning

UserRunning

Preempted

Asleep inMemory

Ready to Runin Memory

Created

Sleep,Swapped

Ready to RunSwapped

Page 9: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

UNIX Process State Transition Diagram (2)

User running: Executing in user mode.

Kernel running: Executing in kernel model.

Ready to run, in memory: Ready to run as soon as the kernel schedules it.

Page 10: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

UNIX Process State Transition Diagram (3)Asleep in memory: unable to execute

until an event occurs; process in main memory.

Ready to run, swapped: process is ready to run, but the the swapper must swap the process into main memory before the kernel can schedule it to execute.

Sleeping, swapped: The process is awaiting an event and has been swapped to secondary storage.

Page 11: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

UNIX Process State Transition Diagram (4)

Preempted: process is returning from kernel to user mode, but the kernel preempts it and does a process switch to schedule another process.

Created: process is newly created and not yet ready to run.

Zombie: process no longer exists, but it leaves a record for its parent process to collect.

Page 12: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Process Control BlockProcess Identification

Process Control BlockThe collection of attributes is refereed to as process control block.

Unique numeric identifier may be an index into the primary

process table

Page 13: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

UNIX Process Control Table

Process IdentifiersID of this process and ID of parent process.

User Identifiersreal user ID, effective user ID

PointersTo U area and process memory (text, data, stack)

Process Size, Priority, Signal, Timers, ......

Page 14: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Processor State Information

Contents of processor registers User-visible registers (data/address register). Control and status registers (program counter,

instruction register. Stack pointers ( points to the top of the stack).

Program status word (PSW) contains status information - indicate the

mode of execution (user or kernel mode) ??????

Page 15: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 1Process Control - Exercise/Home WorkThe VAX/VMS operating system makes use of

four processor access modes as follows:Kernel: Executes the kernel of the VMS operating

system, which includes memory management, interrupt handing, and I/O operations.

Executive: Executes many of the operating system service calls, including file and disk management routines.

Supervisor: Executes other operating system services, such as responses to user command.

User: Execute user programs, plus utilities such as compilers, editors, linkers, and debuggers.

Page 16: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 1Process Control - Exercise/Home Work

a) A number of operating systems have two modes (UNIX), kernel and user. What are the advantages and disadvantages of providing four mode instead of two?

b) Can you make a case for even more than four modes?

Page 17: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Typical Functions of an Operating-System Kernel (1)

Memory ManagementAllocation of address space to processesPage and segment management

I/O ManagementAllocation of I/O channels and devices to

processesSupport Functions

Interrupt handling and accounting

Page 18: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Typical Functions of an Operating-System Kernel (2)

Process ManagementProcess creation and terminationProcess scheduling and dispatchingProcess switchingProcess synchronization and support

for inter-process communication

Page 19: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Receive Message from Child Processes

* wait( ) System Call

* Status Information of wait( )

* Example: communication between parent process and child processes (jg73.cc and jg74.cc)

Page 20: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Process Control Information

Additional information needed by the operating system to control and coordinate the various active processes scheduling and state information data structuring interprocess communication process privileges resource ownership and utilization ??????

Page 21: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 2: Multiple Blocked QueuesProcess Control - Exercise/Home Work

Admit

Ready Queue

Dispatch

Time-out

ReleaseProcessor

Event 1 Wait

Event 1 Queue

Event 1Occurs

Event 2 Wait

Event 2 Queue

Event 2Occurs

Page 22: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 2Process Control - Exercise/Home Work

Figure “Multiple Blocked Queues” suggests that a process can only be in one Event queue at a time.

a) Is it possible that you would to allow a process to wait on more than one event at the same time? Provide an example.

b) In that case, how you modify the queuing structure of the figure to support this new feature?

Page 23: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

When to Switch a Process

Trap error occurred may cause process to be moved to Exit

stateSupervisor call

such as file open

Page 24: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

When to Switch a Process

Memory fault memory address is in virtual memory so

it must be brought into main memoryInterrupts ??????

Clockprocess has executed for the maximum

allowable time slice

I/O

Page 25: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 3Process Control - Exercise/Home Work

In a number of early computers, an interrupt cased the register values to be stored in fixed locations associated with the given interrupt signal.

Under what circumstances is this a practical technique? Explain why it is inconvenient in general.

Page 26: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Execution of the Operating System

Nonprocess Kernel execute kernel outside of any process operating system code is executed as a

separate entity that operates in privileged mode

P1 P2 ..... Pn

Kernel

Page 27: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Execution of the Operating System

Execution Within User Processes operating system software within

context of a user process process executes in privileged mode

when executing operating system code P1 P2 ...... Pn OS OS OSFunctions Functions Functions Process Switching Functions

Page 28: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Execution of the Operating System

Process-Based Operating System major kernel functions are separate

processes a process is invoked by the operating

system

P1 P2 ...... Pn OS1 OS2 ..... OSn

Process Switching Functions

Page 29: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 4Process Control - Exercise/Home Work

UNIX is unsuitable for real-time applications, because a process executing in kernel mode may not be preempted . Elaborate.

P1 P2 ...… Pn OS OS OSFunctions Functions Functions Process Switching Functions

Page 30: Process Control zProcess Control Block (PCB) zProcess State Information zProcess Control Information zFunctions of an Operating-System Kernel zSwitch a.

Question 5Process Control - Exercise/Home Work

The UNIX kernel will dynamically grow a process’s stack in virtual memory as needed, but it will never try to shrink it.

Explain why it would be possible to shrink the stack, and

Why the UNIX kernel does not shrink it.