The
main server??™s only job is to recognize a request and then to create a thread to do the work of responding. This
multithreaded approach keeps the web server responsive to new requests. Multithreading is efficient compared
to the alternative of using multiple processes, because creating a new thread requires about one hundredth the
time that creating a new process requires.
Another advantage of threads appears when the computer contains multiple CPUs. In that case, different
threads can be executed on different CPUs, with the potential for completely parallel execution and great speed
improvement.
Threads can be provided as ???user threads??? or ???kernel threads.??? Threads provided by the OS are kernel
threads. If the OS itself does not support threading, it is possible to implement threading using a user thread
library that executes as a user process. For example, the POSIX thread package is a user thread package
available for UNIX computers.
Kernel threads have the advantages associated with the OS itself being aware of the threads. For instance,
since the OS does the scheduling of the threads, if one thread must wait for some reason (e.g., for I/O to
complete), the OS can schedule another thread from the same process.
Pages:
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282