Upload
independent
View
1
Download
0
Embed Size (px)
Citation preview
Processes
Multiprogramming of 4 programs
Conceptual model of 4 independent, sequential processes
Only one program active at any instant
Principal events that cause process creation
1. System initialization
Execution of process creation system
2. User request to create a new process
3. Initiation of a batch job
Conditions which terminate processes
1. Normal exit (voluntary)
2. Error exit (voluntary)
3. Fatal error (involuntary)
4. Killed by another process (involuntary)
A light weight process
Threads are a way for a program to split itself into two
or more simultaneously or (pseudo-simultaneously)
running tasks
Threads : Process
Description
Example Systems
1:1
Each thread of execution is a
unique process with its own
address space and resources.
Traditional UNIX
implementations
M:1
A process defines an address
space and dynamic resource
ownership. Multiple threads
may be created and executed
within that process.
Windows NT, Solaris,
OS/2,
OS/390, MACH
Threads : Process
Description
Example Systems
1:M
A thread may migrate from one
process environment to
another. This allows a thread
to be easily moved among
distinct systems.
Ra (Clouds), Emerald
M:M
Combines attributes of M:1
and 1:M cases
TRIX
All thread management is done by the application
The kernel is not aware of the existence of threads
Thread management is done by User-Level threads
library
◦ Three primary Thread libraries
1. Posix Pthread
2. Win32 Threads
3. Java Threads
Windows XP, Linux, and Solaris are examples
of this approach
Kernel maintains context information for the
process and the threads
Scheduling is done on a thread basis supported
by kernel
States associated with a change in thread state
◦ Spawn
Spawn another thread
◦ Block
◦ Unblock
◦ Finish
Deallocate register stacks and context
Possible scheduling of kernel-level threads ◦ 50-msec process quantum
◦ threads run 5 msec/CPU burst
Takes less time to create a new thread than a
process
Less time to terminate a thread than a process
Less time to switch between two threads
within the same process
Since threads within the same process share
memory and files, they can communicate with
each other without invoking the kernel
Four conditions to provide Mutual Exclusion
1. No two processes simultaneously in critical region
2. No assumptions made about speeds or numbers of CPUs
3. No process running outside its critical region may block
another process
4. No process must wait forever to enter its critical region