Académique Documents
Professionnel Documents
Culture Documents
Operating Systems
…; …;
} } Stack
A() { A() { A
main
… …
} Program } Process
n More to a process than just a program:
q Program is just part of the process state
q I run Vim or Notepad on lectures.txt, you run it on homework.java – Same
program, different processes
n Less to a process than a program:
q A program can invoke more than one process
q A web browser lunches multiple processes, e.g., one per tab
Process State
new admitted
exit terminated
interrupt
running
ready
Scheduler
I/O or dispatch
event I/O or
completion event wait
waiting
Process States
Device
Queue
Ready
Queue
Ready Queue And Various I/O
Device Queues
Process Scheduling Queues
17
Process Profiles
n Execution
q Parent and child execute concurrently.
q Parent waits until child has terminated.
n Economy
MS/DOS, early
One Traditional UNIX
Macintosh
Embedded systems Mach, OS/2, Linux
(Geoworks, VxWorks, Windows 9x???
Many JavaOS,etc)
Win NT to XP, Solaris,
JavaOS, Pilot(PC) HP-UX, OS X
n Examples
q Windows XP/2000, Solaris, Linux,Tru64 UNIX,
Mac OS X, Mach, OS/2
User Threads
n Supported above the kernel, via a set of library calls
at the user level.
n Thread management done by user-level threads library
q User program provides scheduler and thread package
n May have several user threads per kernel thread
n User threads may be scheduled non-premptively relative to
each other (only switch on yield())
q Advantages
n Cheap, Fast
q Threads do not need to call OS and cause interrupts to kernel
q Disadv: If kernel is single threaded, system call from any
thread can block the entire task.
n Example thread libraries:
q POSIX Pthreads, Win32 threads, Java threads
Multithreading Models
n Many-to-One
n One-to-One
n Many-to-Many
Many-to-One
n Many user-level threads mapped to single
kernel thread
n Examples:
q Solaris Green Threads
q GNU Portable Threads
One-to-One
Examples
q Windows NT/XP/2000; Linux; Solaris 9 and later
Many-to-Many Model
n Allows many user level
threads to be mapped to
many kernel threads
n Allows the operating
system to create a
sufficient number of
kernel threads
n Solaris prior to version 9
n Windows NT/2000 with
the ThreadFiber package
Thread Support in Solaris 2
B
Multiprocessing
C
A B C
Multiprogramming A B C A B C B
Cooperating Processes
of communicating processes?
q What is the capacity of a link?
…….
Direct Communication
n Operations
§ create a new mailbox
§ send/receive messages through mailbox
§ destroy a mailbox
n Issue: Mailbox sharing
§ P1, P2 and P3 share mailbox A.
§ P1 sends message, P2 and P3 receive… who gets
message??
n Possible Solutions
§ disallow links between more than 2 processes
§ allow only one process at a time to execute receive operation
§ allow system to arbitrarily select receiver and then notify
sender.
Message Buffering