UNIT III (2)
UNIT III (2)
UNIT III (2)
Process Management
Process Concept
• Program counter
• CPU registers
• Memory-management information
• Accounting information
Program counter: The counter indicates the address of the next instruction to be
executed for this process.
CPU registers: The registers vary in number and type, depending on the
computer architecture. They include accumulators, index registers, stack
pointers, and general-purpose registers, plus any condition-code information.
Along with the program counter, this state information must be saved when an
interrupt occurs, to allow the process to be continued correctly afterward.
I/O status information: The information includes the list of I/O devices
allocated to this process, a list of open files, and so on.
The PCB simply serves as the repository for any information that may vary
from process to process.
Process State
As a process executes, it changes state
Running State: A process is said to be running if it has the CPU, that is, process
actually using the CPU at that particular instant.
Overview
Multithreading Models
Threading Issues
What is Thread?
A thread is a flow of execution through the process code, with its own program counter
that keeps track of which instruction to execute next, system registers which hold its
current working variables, and a stack which contains the execution history.
A thread shares with its peer threads few information like code segment, data segment
and open files.
2 Process switching needs interaction with operating Thread switching does not need to interact with operating
system. system.
3 In multiple processing environments, each process All threads can share same set of open files, child processes.
executes the same code but has its own memory and file
resources.
4 If one process is blocked, then no other process can While one thread is blocked and waiting, a second thread in
execute until the first process is unblocked. the same task can run.
5 Multiple processes without using threads use more Multiple threaded processes use fewer resources.
resources.
6 In multiple processes each process operates One thread can read, write or change another thread's data.
independently of the others.
Single and Multithreaded Processes
Benefits
Responsiveness
Resource Sharing
Economy
Utilization of MP Architectures
Benefits of Threads
Responsiveness
Multithreading an interactive application may allow a program to continue
running even if part of it is blocked or is performing a lengthy operation,
thereby increasing responsiveness to the use.
Resource Sharing
Since threads within the same process share memory and files, they can
communicate with each other without invoking the kernel
Benefits of Threads (cont.)
Economy
Disadvantages:
When a ULT executes a system call, not only the thread is blocked, but all of the
threads within the process are blocked.
Disadvantage:
More overhead
Multithreading Models
Many-to-One
One-to-One
Many-to-Many
Many-to-One
Clearly, any process that shares data with other processes is a cooperating
process.
Inter-process Communication (IPC)
✦ destroy a mailbox
Solutions
Job message queues are supplied for each job running on the system. Each job is
given an external message queue (*EXT) and each call of an original program
model (OPM) program or Integrated Language Environment (ILE) procedure
within the job has its own call message queue.
Message queues are also supplied for the system history log (QHST) and the
system operator (QSYSOPR).
These message queues are used as follows:
•Workstation message queues are used for sending and receiving messages
between workstation users and between workstation users and the system
operator. The name of the queue is the same as the name of the workstation. The
queue is created by the system when the workstation is described to the system.
•User profile message queues can be used for communication between users.
User profile message queues are automatically created in library QUSRSYS
when the user profile is created.
•Job message queues are used for receiving requests to be processed (such as
commands) and for sending messages that result from processing the requests;
the messages are sent to the requester of the job. Job message queues exist for
each job and only exist for the life of the job. Job message queues consist of an
external message queue (*EXT) and a set of call stack entry message queues.
•System operator message queue (QSYSOPR) is used for receiving and replying
to messages from the system, display station users, and application programs.
•The history log message queue is used for any job in the system to have a
record of high-level system activities.