0% found this document useful (0 votes)
50 views25 pages

Operating System: Session: 2020-21

The document discusses processes in operating systems. It defines a process as a program in execution and describes the different states a process can be in such as running, ready, waiting, etc. It explains process representation using a process control block and the operations involved in process scheduling, creation, and termination. As an example, it outlines the multiprocess architecture of the Chrome browser.

Uploaded by

Javeria Abbasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views25 pages

Operating System: Session: 2020-21

The document discusses processes in operating systems. It defines a process as a program in execution and describes the different states a process can be in such as running, ready, waiting, etc. It explains process representation using a process control block and the operations involved in process scheduling, creation, and termination. As an example, it outlines the multiprocess architecture of the Chrome browser.

Uploaded by

Javeria Abbasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Operating System

Session: 2020-21
Kaleem Nawaz Khan
Senior Lecturer
Department of Computer Science

Bahria University Islamabad Campus


Today’s Agenda
Ø Process Concept
Ø Process Scheduling

Ø Operations on Processes
Process Concept
ØAn operating system executes a variety of programs:
• Batch system – jobs
• Time-shared systems – user programs or tasks
ØTextbook uses the terms job and process almost interchangeably
ØProcess – a program in execution; process execution must progress in sequential fashion
Process Concept
Multiple parts of a process
ØThe program code, also called text section
ØCurrent activity including program counter, processor registers
ØStack containing temporary data
ØFunction parameters, return addresses, local variables
ØData section containing global variables
ØHeap containing memory dynamically allocated during run time
Process Concept
ØProgram is a passive entity stored on disk (executable file), process is active
• Program becomes process when executable file loaded into memory
ØExecution of program started via GUI mouse clicks, command line entry of its name, etc
ØOne program can be several processes
• Consider multiple users executing the same program
Process Concept
Process Concept
Process State
ØAs a process executes, it changes state
• new: The process is being created
• running: Instructions are being executed
• waiting: The process is waiting for some event to occur
• ready: The process is waiting to be assigned to a processor
• terminated: The process has finished execution
Process Concept
Process Concept
Process Control Block (PCB)
ØInformation associated with each process (also called task control block)
ØProcess state – running, waiting, etc
ØProgram counter – location of instruction to next execute
ØCPU registers – contents of all process-centric registers
ØCPU scheduling information- priorities, scheduling queue pointers
ØMemory-management information – memory allocated to the process
ØAccounting information – CPU used, clock time elapsed since start, time
limits
ØI/O status information – I/O devices allocated to process, list of open files
Process Concept
Process Representation in Linux
Represented by the C structure task_struct
pid t_pid; /* process identifier */
long state; /* state of the process */
unsigned int time_slice /* scheduling information */
struct task_struct *parent; /* this process’s parent */
struct list_head children; /* this process’s children */
struct files_struct *files; /* list of open files */
struct mm_struct *mm; /* address space of this process */
Process Concept
CPU Switch From Process to Process
Process Concept
Threads
ØThe process model discussed so far has implied that a process is a program that performs
a single thread of execution.
ØFor example, when a process is running a word-processor program, a single thread of
instructions is being executed.
ØThis single thread of control allows the process to perform only one task at one time.
Ø The user cannot simultaneously type in characters and run the spell checker within the
same process, for example.
ØMany modern operating systems have extended the process concept to allow a process to
have multiple threads of execution and thus to perform more than one task at a time.
Process Scheduling
ØMaximize CPU use, quickly switch processes onto CPU for time sharing
ØProcess scheduler selects among available processes for next execution on CPU
ØMaintains scheduling queues of processes
Ø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
Process Scheduling
Ready Queue And Various
I/O Device Queues
Process Scheduling
Queueing diagram represents
queues, resources, flows
Process Scheduling
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
Process Scheduling
Ø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
Process Scheduling
Medium Term Scheduling
Process Scheduling
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
• The more complex the OS and the PCB => the longer the context switch
ØTime dependent on hardware support
• Some hardware provides multiple sets of registers per CPU => multiple contexts loaded at once
Operations on Processes
ØSystem must provide mechanisms for:
• Process creation,
• Process termination,
• and so on as detailed next
Operations on Processes
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 options
• Parent and children share all resources
• Children share subset of parent’s resources
• Parent and child share no resources
ØExecution options
• Parent and children execute concurrently
• Parent waits until children terminate
Operations on Processes
A Tree of Processes in Linux
init
pid = 1

login kthreadd sshd


pid = 8415 pid = 2 pid = 3028

bash khelper pdflush sshd


pid = 8416 pid = 6 pid = 200 pid = 3610

emacs tcsch
ps
pid = 9204 pid = 4005
pid = 9298
Operations on Processes
C Program Forking Separate Process
Operations on Processes
Process Termination
ØProcess executes last statement and then asks the operating system to delete it using the
exit() system call.
• Returns status data from child to parent (via wait())
• Process’ resources are deallocated by operating system
ØParent may terminate the execution of children processes using the abort() system call.
Some reasons for doing so:
• Child has exceeded allocated resources
• Task assigned to child is no longer required
• The parent is exiting and the operating systems does not allow a child to continue if its parent
terminates
Operations on Processes
Multiprocess Architecture – Chrome Browser
ØMany web browsers ran as single process (some still do)
• If one web site causes trouble, entire browser can hang or crash
ØGoogle Chrome Browser is multiprocess with 3 different types of processes:
• Browser process manages user interface, disk and network I/O
• Renderer process renders web pages, deals with HTML, Javascript. A new renderer created for
each website opened
• Runs in sandbox restricting disk and network I/O, minimizing effect of security exploits
• Plug-in process for each type of plug-in

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy