THREADS

OS creating a new process involves a lot of work

example: Web server processing CGI scripts each in a new process

example: suppose you have multiple CPUs in your PC and want to use them to multiply matrices with a parallel algorithm

example: a Web server with a RAM cache of recently accessed Web pages

example: word processor

example: virus scanner

example: browser

using threads

example: browser

analogies:

all processes start out with a single thread and that thread may create other threads in the process

to implement multiple threads in a process

all threads in all processes are scheduled round-robin on the CPU(s)

using multiple threads makes a program easier to write and execute more quickly, particularly if there are multiple CPUs available to dedicate to threads

example: a Web server with a RAM cache of recently accessed Web pages

what remains is the issue of safely sharing data to avoid or prevent race conditions and deadlock, in other words, synchronization of multiple threads sharing data


home page: http://elvis.rowan.edu/~hartley/index.html
e-mail: hartley@elvis.rowan.edu