SlideShare a Scribd company logo
3.1 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Process
An operating system executes a variety of programs:
Batch system – jobs
Time-shared systems – user programs or tasks
Process – a program in execution; process execution must
progress in sequential fashion
A process includes:
program counter
stack
data section
Topics:
Operations in Process
Scheduling
Interprocess Communication
3.2 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Process in Memory
3.3 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
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
3.4 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Process States and Transition
3.5 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Process Control Block (PCB)
3.6 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
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
3.7 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
CPU Switch From Process to Process
3.8 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
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)
Options in Resource sharing
Parent and children share all resources
Children share subset of parent’s resources
Parent and child share no resources
Options Execution
Parent and children execute concurrently
Parent waits until children terminate
3.9 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Process Creation (Cont.)
Options n 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
3.10 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Unix Fork/Exec/Exit/Wait Example
int pid = fork();
Create a new process that is a
clone of its parent.
exec*(“program” [, argvp, envp]);
Overlay the calling process
virtual memory with a new
program, and transfer control
to it.
exit(status);
Exit with status, destroying the
process.
int pid = wait*(&status);
Wait for exit (or other status
change) of a child.
fork parent fork child
wait exit
exec
initialize
child
context
3.11 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Example: Process Creation in Unix
int pid;
int status = 0;
if (pid = fork()) {
/* parent */
…..
pid = wait(&status);
} else {
/* child */
…..
exit(status);
}
Parent uses wait to sleep
until the child exits; wait
returns child pid and
status.
Wait variants allow wait
on a specific child, or
notification of stops and
other signals.
The fork syscall
returns twice: it
returns a zero to the
child and the child
process ID (pid) to the
parent.
3.12 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
C Program Forking Separate Process
int main()
{
int pid;
/* fork another process */
pid = fork();
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
exit(-1);
}
else if (pid == 0) { /* child process */
execlp("/bin/ls", "ls", NULL);
}
else { /* parent process */
/* parent will wait for the child to
complete */
wait (NULL);
printf ("Child Complete");
exit(0);
}
}
3.14 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
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
3.15 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Communications Models: Shared
memory or Message Passing
3.16 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Synchronization
Message passing may be either blocking or non-blocking
Blocking is considered synchronous
Blocking send has the sender block until the message is
received
Blocking receive has the receiver block until a message is
available
Non-blocking is considered asynchronous
Non-blocking send has the sender send the message and
continue
Non-blocking receive has the receiver receive a valid
message or null
3.17 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Motivation for multi-threaded servers
3.18 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Single and Multithreaded Processes
3.19 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Benefits
Responsiveness
Resource Sharing
Economy
Scalability
3.20 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Kernel Threads
Recognized and supported by the OS Kernel
OS explicitly performs scheduling and context switching of kernel threads
Examples
Windows XP/2000
Solaris
Linux
Tru64 UNIX
Mac OS X
3.21 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
User Threads
Thread management done by user-level threads library
OS kernel does not know/recognize there are multiple threads running
in a user program.
The user program (library) is responsible for scheduling and context
switching of its threads.
Three primary thread libraries:
POSIX Pthreads
Win32 threads
Java threads
3.22 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
User- vs. Kernel-level Threads
From W. Stallings, Operating Systems, 6th
Edition
3.23 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Pthreads
May be provided either as user-level or kernel-level
A POSIX standard (IEEE 1003.1c) API for thread creation and
synchronization
API specifies behavior of the thread library, implementation is up to
development of the library
Common in UNIX operating systems (Solaris, Linux, Mac OS X)
3.24 Silberschatz, Galvin and GagneOperating System Concepts – 8th
Edition
Java Threads
Java threads are managed by the JVM
Typically implemented using the threads model provided by
underlying OS
Java threads may be created by:
Extending Thread class
Implementing the Runnable interface

More Related Content

What's hot

Processes description and process control.
Processes description and process control.Processes description and process control.
Processes description and process control.
Ahsan Rahim
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
Deadlock
DeadlockDeadlock
Deadlock
Rajandeep Gill
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
cscarcas
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
Vaibhav Khanna
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Riya Choudhary
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 
Operating system - Process and its concepts
Operating system - Process and its conceptsOperating system - Process and its concepts
Operating system - Process and its concepts
Karan Thakkar
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
Transweb Global Inc
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
Neel Patel
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System Structures
Shafaan Khaliq Bhatti
 
Complete Operating System notes
Complete Operating System notesComplete Operating System notes
Complete Operating System notes
Lakshmi Sarvani Videla
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
sathish sak
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
Khushboo Jain
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
J.T.A.JONES
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
rprajat007
 
Shortest Job First
Shortest Job FirstShortest Job First
Shortest Job First
ShubhamGupta345141
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
ritu98
 

What's hot (20)

Processes description and process control.
Processes description and process control.Processes description and process control.
Processes description and process control.
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
Deadlock
DeadlockDeadlock
Deadlock
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Memory management
Memory managementMemory management
Memory management
 
Operating system - Process and its concepts
Operating system - Process and its conceptsOperating system - Process and its concepts
Operating system - Process and its concepts
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System Structures
 
Complete Operating System notes
Complete Operating System notesComplete Operating System notes
Complete Operating System notes
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Shortest Job First
Shortest Job FirstShortest Job First
Shortest Job First
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
 

Similar to Process threads operating system.

ch03.pptx
ch03.pptxch03.pptx
ch03.pptx
SHIKHAARYA26
 
ch3.pptx
ch3.pptxch3.pptx
ch3.pptx
HuyNguyn660008
 
Chapter 3 Processes (1)Operating systems.pptx
Chapter 3  Processes (1)Operating systems.pptxChapter 3  Processes (1)Operating systems.pptx
Chapter 3 Processes (1)Operating systems.pptx
RoyHanzala
 
ch3.pptx
ch3.pptxch3.pptx
ch3.pptx
ZoYaKazmi3
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
SonaliAjankar
 
Unit II - 1 - Operating System Process
Unit II - 1 - Operating System ProcessUnit II - 1 - Operating System Process
Unit II - 1 - Operating System Process
cscarcas
 
Processes
ProcessesProcesses
Processes
RezaSony
 
2.ch3 Process (1).ppt
2.ch3 Process (1).ppt2.ch3 Process (1).ppt
2.ch3 Process (1).ppt
salihazameer
 
Ch3OperSys
Ch3OperSysCh3OperSys
Ch3OperSys
Dwight Sabio
 
OperatingSystemChp3
OperatingSystemChp3OperatingSystemChp3
OperatingSystemChp3
Dwight Sabio
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
Kathirvel Ayyaswamy
 
ch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptxch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptx
AKumaraGuru
 
3.Process Management
3.Process Management3.Process Management
3.Process Management
Senthil Kanth
 
Week03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhgWeek03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhg
alianwar88
 
3 processes
3 processes3 processes
3 processes
BaliThorat1
 
ch3_smu.ppt
ch3_smu.pptch3_smu.ppt
ch3_smu.ppt
JubayerPial
 
ch3-lect7.pptx
ch3-lect7.pptxch3-lect7.pptx
ch3-lect7.pptx
haroon451422
 
CH03.pdf
CH03.pdfCH03.pdf
CH03.pdf
ImranKhan880955
 

Similar to Process threads operating system. (20)

14712-l4.pptx
14712-l4.pptx14712-l4.pptx
14712-l4.pptx
 
ch03.pptx
ch03.pptxch03.pptx
ch03.pptx
 
ch3.pptx
ch3.pptxch3.pptx
ch3.pptx
 
Chapter 3 Processes (1)Operating systems.pptx
Chapter 3  Processes (1)Operating systems.pptxChapter 3  Processes (1)Operating systems.pptx
Chapter 3 Processes (1)Operating systems.pptx
 
ch3.pptx
ch3.pptxch3.pptx
ch3.pptx
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Unit II - 1 - Operating System Process
Unit II - 1 - Operating System ProcessUnit II - 1 - Operating System Process
Unit II - 1 - Operating System Process
 
Processes
ProcessesProcesses
Processes
 
2.ch3 Process (1).ppt
2.ch3 Process (1).ppt2.ch3 Process (1).ppt
2.ch3 Process (1).ppt
 
Ch3OperSys
Ch3OperSysCh3OperSys
Ch3OperSys
 
OperatingSystemChp3
OperatingSystemChp3OperatingSystemChp3
OperatingSystemChp3
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
 
ch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptxch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptx
 
3.Process Management
3.Process Management3.Process Management
3.Process Management
 
Week03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhgWeek03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhg
 
3 processes
3 processes3 processes
3 processes
 
ch3_smu.ppt
ch3_smu.pptch3_smu.ppt
ch3_smu.ppt
 
ch3-lect7.pptx
ch3-lect7.pptxch3-lect7.pptx
ch3-lect7.pptx
 
CH03.pdf
CH03.pdfCH03.pdf
CH03.pdf
 
ch3 (1).ppt
ch3 (1).pptch3 (1).ppt
ch3 (1).ppt
 

More from Reham Maher El-Safarini

Ux
Ux Ux
Global threat-landscape report by fortinet.
Global threat-landscape report by fortinet.Global threat-landscape report by fortinet.
Global threat-landscape report by fortinet.
Reham Maher El-Safarini
 
Dynamics AX/ X++
Dynamics AX/ X++Dynamics AX/ X++
Dynamics AX/ X++
Reham Maher El-Safarini
 
Microsoft sql-and-the-gdpr
Microsoft sql-and-the-gdprMicrosoft sql-and-the-gdpr
Microsoft sql-and-the-gdpr
Reham Maher El-Safarini
 
AWS Cloud economics
AWS Cloud economicsAWS Cloud economics
AWS Cloud economics
Reham Maher El-Safarini
 
Cloud skills development
Cloud skills developmentCloud skills development
Cloud skills development
Reham Maher El-Safarini
 
AWS cloud adoption framework (caf)
AWS cloud adoption framework (caf)AWS cloud adoption framework (caf)
AWS cloud adoption framework (caf)
Reham Maher El-Safarini
 
Application and database migration workshop
Application and database migration workshopApplication and database migration workshop
Application and database migration workshop
Reham Maher El-Safarini
 
Containers on AWS
Containers on AWSContainers on AWS
Containers on AWS
Reham Maher El-Safarini
 
Security and governance with aws control tower and aws organizations
Security and governance with aws control tower and aws organizationsSecurity and governance with aws control tower and aws organizations
Security and governance with aws control tower and aws organizations
Reham Maher El-Safarini
 
Digital transformation on aws
Digital transformation on awsDigital transformation on aws
Digital transformation on aws
Reham Maher El-Safarini
 
Security in the cloud
Security in the cloudSecurity in the cloud
Security in the cloud
Reham Maher El-Safarini
 
2. migration, disaster recovery and business continuity in the cloud
2. migration, disaster recovery and business continuity in the cloud2. migration, disaster recovery and business continuity in the cloud
2. migration, disaster recovery and business continuity in the cloud
Reham Maher El-Safarini
 
1. aws overview
1. aws overview1. aws overview
1. aws overview
Reham Maher El-Safarini
 
Pgp
PgpPgp
ssl for securing
ssl for securingssl for securing
ssl for securing
Reham Maher El-Safarini
 
03 unity 3_d_part_2
03 unity 3_d_part_203 unity 3_d_part_2
03 unity 3_d_part_2
Reham Maher El-Safarini
 
01 unity 3_d_introduction
01 unity 3_d_introduction01 unity 3_d_introduction
01 unity 3_d_introduction
Reham Maher El-Safarini
 
unity basics
unity basicsunity basics

More from Reham Maher El-Safarini (20)

Ux
Ux Ux
Ux
 
Global threat-landscape report by fortinet.
Global threat-landscape report by fortinet.Global threat-landscape report by fortinet.
Global threat-landscape report by fortinet.
 
Dynamics AX/ X++
Dynamics AX/ X++Dynamics AX/ X++
Dynamics AX/ X++
 
Microsoft sql-and-the-gdpr
Microsoft sql-and-the-gdprMicrosoft sql-and-the-gdpr
Microsoft sql-and-the-gdpr
 
AWS Cloud economics
AWS Cloud economicsAWS Cloud economics
AWS Cloud economics
 
Cloud skills development
Cloud skills developmentCloud skills development
Cloud skills development
 
AWS cloud adoption framework (caf)
AWS cloud adoption framework (caf)AWS cloud adoption framework (caf)
AWS cloud adoption framework (caf)
 
Application and database migration workshop
Application and database migration workshopApplication and database migration workshop
Application and database migration workshop
 
Containers on AWS
Containers on AWSContainers on AWS
Containers on AWS
 
Security and governance with aws control tower and aws organizations
Security and governance with aws control tower and aws organizationsSecurity and governance with aws control tower and aws organizations
Security and governance with aws control tower and aws organizations
 
Digital transformation on aws
Digital transformation on awsDigital transformation on aws
Digital transformation on aws
 
Security in the cloud
Security in the cloudSecurity in the cloud
Security in the cloud
 
2. migration, disaster recovery and business continuity in the cloud
2. migration, disaster recovery and business continuity in the cloud2. migration, disaster recovery and business continuity in the cloud
2. migration, disaster recovery and business continuity in the cloud
 
1. aws overview
1. aws overview1. aws overview
1. aws overview
 
Pgp
PgpPgp
Pgp
 
ssl for securing
ssl for securingssl for securing
ssl for securing
 
03 unity 3_d_part_2
03 unity 3_d_part_203 unity 3_d_part_2
03 unity 3_d_part_2
 
02 unity 3_d_part_1
02 unity 3_d_part_102 unity 3_d_part_1
02 unity 3_d_part_1
 
01 unity 3_d_introduction
01 unity 3_d_introduction01 unity 3_d_introduction
01 unity 3_d_introduction
 
unity basics
unity basicsunity basics
unity basics
 

Recently uploaded

In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
AlaminAfendy1
 
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Sérgio Sacani
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
fafyfskhan251kmf
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptx
muralinath2
 
Chapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisisChapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisis
tonzsalvador2222
 
Seminar of U.V. Spectroscopy by SAMIR PANDA
 Seminar of U.V. Spectroscopy by SAMIR PANDA Seminar of U.V. Spectroscopy by SAMIR PANDA
Seminar of U.V. Spectroscopy by SAMIR PANDA
SAMIR PANDA
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
Columbia Weather Systems
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
Scintica Instrumentation
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
sanjana502982
 
GBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram StainingGBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram Staining
Areesha Ahmad
 
role of pramana in research.pptx in science
role of pramana in research.pptx in sciencerole of pramana in research.pptx in science
role of pramana in research.pptx in science
sonaliswain16
 
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Ana Luísa Pinho
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Sérgio Sacani
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
YOGESH DOGRA
 
S.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary levelS.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary level
ronaldlakony0
 
erythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptxerythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptx
muralinath2
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
ChetanK57
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
RenuJangid3
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
kejapriya1
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
Richard Gill
 

Recently uploaded (20)

In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
 
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptx
 
Chapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisisChapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisis
 
Seminar of U.V. Spectroscopy by SAMIR PANDA
 Seminar of U.V. Spectroscopy by SAMIR PANDA Seminar of U.V. Spectroscopy by SAMIR PANDA
Seminar of U.V. Spectroscopy by SAMIR PANDA
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
 
GBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram StainingGBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram Staining
 
role of pramana in research.pptx in science
role of pramana in research.pptx in sciencerole of pramana in research.pptx in science
role of pramana in research.pptx in science
 
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
 
S.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary levelS.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary level
 
erythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptxerythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptx
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
 

Process threads operating system.

  • 1. 3.1 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Process An operating system executes a variety of programs: Batch system – jobs Time-shared systems – user programs or tasks Process – a program in execution; process execution must progress in sequential fashion A process includes: program counter stack data section Topics: Operations in Process Scheduling Interprocess Communication
  • 2. 3.2 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Process in Memory
  • 3. 3.3 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition 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
  • 4. 3.4 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Process States and Transition
  • 5. 3.5 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Process Control Block (PCB)
  • 6. 3.6 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition 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
  • 7. 3.7 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition CPU Switch From Process to Process
  • 8. 3.8 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition 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) Options in Resource sharing Parent and children share all resources Children share subset of parent’s resources Parent and child share no resources Options Execution Parent and children execute concurrently Parent waits until children terminate
  • 9. 3.9 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Process Creation (Cont.) Options n 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
  • 10. 3.10 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Unix Fork/Exec/Exit/Wait Example int pid = fork(); Create a new process that is a clone of its parent. exec*(“program” [, argvp, envp]); Overlay the calling process virtual memory with a new program, and transfer control to it. exit(status); Exit with status, destroying the process. int pid = wait*(&status); Wait for exit (or other status change) of a child. fork parent fork child wait exit exec initialize child context
  • 11. 3.11 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Example: Process Creation in Unix int pid; int status = 0; if (pid = fork()) { /* parent */ ….. pid = wait(&status); } else { /* child */ ….. exit(status); } Parent uses wait to sleep until the child exits; wait returns child pid and status. Wait variants allow wait on a specific child, or notification of stops and other signals. The fork syscall returns twice: it returns a zero to the child and the child process ID (pid) to the parent.
  • 12. 3.12 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition C Program Forking Separate Process int main() { int pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execlp("/bin/ls", "ls", NULL); } else { /* parent process */ /* parent will wait for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0); } }
  • 13. 3.14 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition 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
  • 14. 3.15 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Communications Models: Shared memory or Message Passing
  • 15. 3.16 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Synchronization Message passing may be either blocking or non-blocking Blocking is considered synchronous Blocking send has the sender block until the message is received Blocking receive has the receiver block until a message is available Non-blocking is considered asynchronous Non-blocking send has the sender send the message and continue Non-blocking receive has the receiver receive a valid message or null
  • 16. 3.17 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Motivation for multi-threaded servers
  • 17. 3.18 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Single and Multithreaded Processes
  • 18. 3.19 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Benefits Responsiveness Resource Sharing Economy Scalability
  • 19. 3.20 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Kernel Threads Recognized and supported by the OS Kernel OS explicitly performs scheduling and context switching of kernel threads Examples Windows XP/2000 Solaris Linux Tru64 UNIX Mac OS X
  • 20. 3.21 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition User Threads Thread management done by user-level threads library OS kernel does not know/recognize there are multiple threads running in a user program. The user program (library) is responsible for scheduling and context switching of its threads. Three primary thread libraries: POSIX Pthreads Win32 threads Java threads
  • 21. 3.22 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition User- vs. Kernel-level Threads From W. Stallings, Operating Systems, 6th Edition
  • 22. 3.23 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Pthreads May be provided either as user-level or kernel-level A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization API specifies behavior of the thread library, implementation is up to development of the library Common in UNIX operating systems (Solaris, Linux, Mac OS X)
  • 23. 3.24 Silberschatz, Galvin and GagneOperating System Concepts – 8th Edition Java Threads Java threads are managed by the JVM Typically implemented using the threads model provided by underlying OS Java threads may be created by: Extending Thread class Implementing the Runnable interface