SlideShare a Scribd company logo
6
Most read
13
Most read
23
Most read
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

PPTX
CPU Scheduling in OS Presentation
PPTX
Deadlock ppt
PPT
Scheduling algorithms
PPTX
Deadlock Prevention
PPTX
cpu scheduling
PPT
Parallel algorithms
PPTX
Process synchronization
CPU Scheduling in OS Presentation
Deadlock ppt
Scheduling algorithms
Deadlock Prevention
cpu scheduling
Parallel algorithms
Process synchronization

What's hot (20)

PPT
deadlock avoidance
PDF
Semaphores
PPT
17 cpu scheduling and scheduling criteria
PPTX
Operating system Dead lock
PPTX
Segmentation in Operating Systems.
PPTX
Fundamentals of operating system
PPT
Process Scheduling
PPTX
INTER PROCESS COMMUNICATION (IPC).pptx
PPT
Introduction to System Calls
PPT
CPU Scheduling Algorithms
PPTX
Process scheduling
PDF
Process scheduling (CPU Scheduling)
PPTX
contiguous memory allocation.pptx
PPTX
Chapter 10 Operating Systems silberschatz
PPTX
Process scheduling
PPTX
PPT
Operating system.ppt (1)
PPTX
Types Of Operating Systems
PPT
Cache memory presentation
deadlock avoidance
Semaphores
17 cpu scheduling and scheduling criteria
Operating system Dead lock
Segmentation in Operating Systems.
Fundamentals of operating system
Process Scheduling
INTER PROCESS COMMUNICATION (IPC).pptx
Introduction to System Calls
CPU Scheduling Algorithms
Process scheduling
Process scheduling (CPU Scheduling)
contiguous memory allocation.pptx
Chapter 10 Operating Systems silberschatz
Process scheduling
Operating system.ppt (1)
Types Of Operating Systems
Cache memory presentation
Ad

Similar to Process threads operating system. (20)

PDF
Ch3OperSys
PDF
OperatingSystemChp3
PPTX
ch3-lect7.pptx
PDF
Ch3 processes
PPT
ch3.ppt
PPTX
Chapter 3 Processes (1)Operating systems.pptx
PPTX
ch3_LU6_LU7_Lecture_1691052564579.pptx
PPTX
ch3.pptx
PPTX
14712-l4.pptx
PPTX
ch3.pptx
PPT
Chapter 3: Processes
PPT
3.Process Management
PPT
ch3_smu.ppt
PPTX
Operating systems Week 3 Processes 01-10-2018.pptx
PPT
Chapter 3
PDF
Unit II - 1 - Operating System Process
PPTX
Processes
PPTX
OPERATING SYSTEM UNIT 2 for paper and knowlekdge
PPTX
ch03.pptx
PPT
CPU Process Synchronization (Chapter 3).pptx
Ch3OperSys
OperatingSystemChp3
ch3-lect7.pptx
Ch3 processes
ch3.ppt
Chapter 3 Processes (1)Operating systems.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptx
ch3.pptx
14712-l4.pptx
ch3.pptx
Chapter 3: Processes
3.Process Management
ch3_smu.ppt
Operating systems Week 3 Processes 01-10-2018.pptx
Chapter 3
Unit II - 1 - Operating System Process
Processes
OPERATING SYSTEM UNIT 2 for paper and knowlekdge
ch03.pptx
CPU Process Synchronization (Chapter 3).pptx
Ad

More from Reham Maher El-Safarini (20)

PDF
Global threat-landscape report by fortinet.
PDF
Dynamics AX/ X++
PDF
Microsoft sql-and-the-gdpr
PDF
AWS Cloud economics
PDF
Cloud skills development
PDF
AWS cloud adoption framework (caf)
PDF
Application and database migration workshop
PDF
Containers on AWS
PDF
Security and governance with aws control tower and aws organizations
PDF
Digital transformation on aws
PDF
Security in the cloud
PDF
2. migration, disaster recovery and business continuity in the cloud
PDF
1. aws overview
PPT
ssl for securing
PPTX
03 unity 3_d_part_2
PPTX
02 unity 3_d_part_1
PPTX
01 unity 3_d_introduction
PPTX
Global threat-landscape report by fortinet.
Dynamics AX/ X++
Microsoft sql-and-the-gdpr
AWS Cloud economics
Cloud skills development
AWS cloud adoption framework (caf)
Application and database migration workshop
Containers on AWS
Security and governance with aws control tower and aws organizations
Digital transformation on aws
Security in the cloud
2. migration, disaster recovery and business continuity in the cloud
1. aws overview
ssl for securing
03 unity 3_d_part_2
02 unity 3_d_part_1
01 unity 3_d_introduction

Recently uploaded (20)

PPTX
7. General Toxicologyfor clinical phrmacy.pptx
PPTX
Comparative Structure of Integument in Vertebrates.pptx
PDF
diccionario toefl examen de ingles para principiante
PPTX
Microbiology with diagram medical studies .pptx
PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PDF
AlphaEarth Foundations and the Satellite Embedding dataset
PDF
bbec55_b34400a7914c42429908233dbd381773.pdf
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
DOCX
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
PDF
MIRIDeepImagingSurvey(MIDIS)oftheHubbleUltraDeepField
PPTX
Cell Membrane: Structure, Composition & Functions
PDF
HPLC-PPT.docx high performance liquid chromatography
PDF
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
PPTX
Introduction to Fisheries Biotechnology_Lesson 1.pptx
7. General Toxicologyfor clinical phrmacy.pptx
Comparative Structure of Integument in Vertebrates.pptx
diccionario toefl examen de ingles para principiante
Microbiology with diagram medical studies .pptx
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
AlphaEarth Foundations and the Satellite Embedding dataset
bbec55_b34400a7914c42429908233dbd381773.pdf
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
Classification Systems_TAXONOMY_SCIENCE8.pptx
INTRODUCTION TO EVS | Concept of sustainability
Phytochemical Investigation of Miliusa longipes.pdf
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
MIRIDeepImagingSurvey(MIDIS)oftheHubbleUltraDeepField
Cell Membrane: Structure, Composition & Functions
HPLC-PPT.docx high performance liquid chromatography
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
Introduction to Fisheries Biotechnology_Lesson 1.pptx

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