Next: About this document
Up: No Title
Previous: Before we go further
- A Thread is a sequential execution stream within a process,
sometimes also called a 'lightweight' process
- There are therefore, multiple threads within a process
- each has a stack, PC and registers (own copy)
- share data and code
- sharing of state, like contents of memory (global variables, heap),
file system
- The address space constitutes all the addresses that are needed
by a program - providing the illusion that the program is running on its own
machine
- Possible to have multiple threads per address space (such as in Solaris)
- Although if only a single thread in an address space, there is a large
similarity between threads and processes
- Keep the distinction between threads and address space :
The address space encapsulates protection (preventing a buggy program from
messing everything else on the system), whereas a thread encapsulates
concurrency.
- Threads within a process belong to a single user
- Threads, like processes, can either belong to the user or the kernel
(user level threads are in invisible to kernel, and provide faster switching)
- Very efficient switching
- Usually no preemption within threads
- Also, sometimes protection between threads is revoked
Examples of multithreaded applications include :
- Robot control : single program, multiple concurrent operation.
- Network server : single program, must handle concurrent requests from
multiple users (web servers).
- Windowing systems : one thread per window.
- Parallel Programming : split program into multiple threads to make it
run faster. Often called multiprogramming
Hence :
Multiprogramming : Multiple jobs or processes
Multiprocessing : Mutiple processors or CPUs.
To confuse matters even further, some multiprocessors are in fact
uniprogrammed - i.e. use of multiple threads in one address space, but only
run one program at a time.
Examples of multithreaded operating systems :
- MS/DOS : one thread, one address space
- traditional Unix : one thread per address space, many address
spaces
- WinNT, Unix (Solaris, HPUX), CMU Mach - many threads per address
space, many address spaces
- Pilot (the OS on the first personal computer ever
built)- many threads, one address space (no protection! - single user no
need for protection).
Hence :
Depending on the context, Processes could be viewed as the
unit of resource allocation and Threads the unit of execution
and the active entities which need to communicate.
Next: About this document
Up: No Title
Previous: Before we go further
Omer F Rana
Thu Feb 6 16:13:26 GMT 1997