0% found this document useful (0 votes)
29 views

PCB and Process Operations

Processes allow multiple programs to run concurrently. A process control block stores information about each process like state and memory. Processes move between ready, running, and blocked states. Schedulers select which process runs on the CPU and when to switch contexts between processes.

Uploaded by

Amar Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

PCB and Process Operations

Processes allow multiple programs to run concurrently. A process control block stores information about each process like state and memory. Processes move between ready, running, and blocked states. Schedulers select which process runs on the CPU and when to switch contexts between processes.

Uploaded by

Amar Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Processes

Processes
• Process Scheduling
• Operations on Processes
Objectives
• To describe the various features of processes,
including scheduling, creation and termination,
and communication
• To describe communication in client-server
systems
• Degree of multiprogramming
– No. of processes running at any point of time in CPU
• Process table
– An array or table consisting the list of all the processes
Process Control Block (PCB)
Information associated with each process
• Process state
• Program counter
• CPU registers
• CPU scheduling information
• Memory-management information
• Accounting information
• I/O status information
Process Control Block (PCB)
CPU Switch From Process to Process(Context Switch)
Process Scheduling Queues
• Job queue – set of all processes in the system
• Ready queue – set of all processes residing in main
memory, ready and waiting to execute
• Device queues – set of processes waiting for an I/O
device
• Processes migrate among the various queues
Ready Queue And Various I/O Device Queues
Representation of Process
Scheduling
Schedulers
• Long-term scheduler (or job scheduler) – selects
which processes should be brought into the ready
queue
• Short-term scheduler (or CPU scheduler) – selects
which process should be executed next and allocates
CPU
Schedulers
• Short-term scheduler (or CPU scheduler) – selects which process should be
executed next and allocates CPU
– Sometimes the only scheduler in a system
– Short-term scheduler is invoked frequently (milliseconds)  (must be fast)
• Long-term scheduler (or job scheduler) – selects which processes should be
brought into the ready queue
– Long-term scheduler is invoked infrequently (seconds, minutes)  (may be
slow)
– The long-term scheduler controls the degree of multiprogramming
• Processes can be described as either:
– I/O-bound process – spends more time doing I/O than computations, many
short CPU bursts
– CPU-bound process – spends more time doing computations; few very long
CPU bursts
• Long-term scheduler strives for good process mix
Addition of Medium Term Scheduling
 Medium-term scheduler can be added if degree of multiple
programming needs to decrease
 Remove process from memory, store on disk, bring back in
from disk to continue execution: swapping
Multitasking in Mobile Systems
• Some mobile systems (e.g., early version of iOS) allow only
one process to run, others suspended
• iOS provides
– Single foreground process- controlled via user interface
– Multiple background processes– in memory, running,
but not on the display, and with limits
– Limits include single, short task, receiving notification of
events, specific long-running tasks like audio playback
• Android runs foreground and background, with fewer limits
– Background process uses a service to perform tasks
– Service can keep running even if background process is
suspended
– Service has no user interface, small memory use
Context Switch
• When CPU switches to another process, the system must save
the state of the old process and load the saved state for the
new process via a context switch
• Context of a process represented in the PCB
• Context-switch time is overhead; the system does no useful
work while switching
• Time dependent on hardware support
Process Creation
• Parent process create children processes, which, in turn
create other processes, forming a tree of processes
• Generally, process identified and managed via a process
identifier (pid)
• Resource sharing
– Parent and children share all resources
– Children share subset of parent’s resources
– Parent and child share no resources
• Execution
– Parent and children execute concurrently
– Parent waits until children terminate
Process Creation (Cont)
• Address space
– Child duplicate of parent
– Child has a program loaded into it
• UNIX examples
– fork system call creates new process
– exec system call used after a fork to replace the process’
memory space with a new program
C Program Forking Separate Process
Process termination
 Termination
• 7 ways of dying:
• Normal completion.
• Time out (e.g. user terminal idle).
• OS intervention (e.g. deadlock).
• Parent dies/is killed.
• Parent kills child.
• Error condition (e.g. memory violation/ zero divide).
• Memory unavailable.
Process Termination
• Process executes last statement and asks the operating
system to delete it (exit)
– Output data from child to parent (via wait)
– Process’ resources are deallocated by operating system
• Parent may terminate execution of children processes
(abort)
– Child has exceeded allocated resources
– Task assigned to child is no longer required
– If parent is exiting
• Some operating system do not allow child to continue
if its parent terminates
– All children terminated - cascading termination
What is operating system?

a) collection of programs that manages


hardware resources
b) system service provider to the application
programs
c) link to interface the hardware and
application programs
d) all of the mentioned
To access the services of operating system,
the interface is provided by the

a) system calls
b) API
c) library
d) assembly instructions
Which one of the following is not
true?
a) kernel is the program that constitutes the
central core of the operating system
b) kernel is the first part of operating system
to load into memory during booting
c) kernel is made of various modules which
can not be loaded in running operating system
d) kernel remains in the memory during the
entire computer session
In operating system, each process
has its own

a) address space and global variables


b) open files
c) pending alarms, signals and signal handlers
d) all of the mentioned
What is the ready state of a
process?
a) when process is unable to run until some task
has been completed

b) when process is scheduled to run after


some execution

c) when process is using the CPU

d) none of the mentioned


The meaning of DWORD parameter in ReadFile()
function (a function for reading from a file) in
the Win32 API is
1. a buffer where the data will be read into and
written from
2. the number of bytes to be read into the buffer
3. the number of bytes read during the last read
4. number of bytes read during the last read
In tightly coupled system or parallel
systems, the processor shares the
following
1. no sharing at all
2. memory and clock
3. only memory is shared, not the
clock
4. only clock is shared, memory is not
shared
In loosely coupled system or distributed
systems, the processor shares the following
1. memory and clock
2. only memory is shared, not the clock
3. no sharing at all
4. only clock is shared, memory is not shared

You might also like