process control zprocess control block (pcb) zprocess state information zprocess control information...
Post on 22-Dec-2015
219 views
TRANSCRIPT
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
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
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
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
File Tables
Existence of filesLocation on secondary memoryCurrent StatusAttributesSometimes this information is
maintained by a file-management system(Think about struct stat and stat( ) )
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( ) )
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
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
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.
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.
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.
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
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, ......
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) ??????
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.
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?
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
Typical Functions of an Operating-System Kernel (2)
Process ManagementProcess creation and terminationProcess scheduling and dispatchingProcess switchingProcess synchronization and support
for inter-process communication
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)
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 ??????
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
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?
When to Switch a Process
Trap error occurred may cause process to be moved to Exit
stateSupervisor call
such as file open
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
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.
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
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
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
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