3. Adierent thread in my-custom-pool, called the B1 thread in this example, picks up the
requestqueued by A1. B1 completes the request and returns to the wait stage.
4. TheA1 thread wakes up and continues processing the request. It executes the ObjectType
SAFand moves on to the Service function.
5. Becausethe Service function must be processed by a thread in my-custom-pool2, the A1
threadqueues the request to my-custom-pool2.
6. Adierent thread in my-custom-pool2, called C1 in this example, picks up the queued
request.C1 completes the request and returns to the wait stage.
7. TheA1 thread wakes up and continues processing the request.
Inthis example, three threads, A1, B1, and C1 work to complete the request.
Additionalthread pools are a way to run thread-unsafe plug-ins. By dening a pool with a
maximumnumber of threads set to 1, only one request is allowed into the specied service
function.In the previous example, if testmod_service is not thread-safe, it must be executed
bya single thread. If you create a single thread in the my-custom-pool2, the SAF works in a
multi-threadedWeb Server.
Formore information on dening thread pools, see “thread-pool-init” in Sun Java System Web
Server7.0 Update 1 Administrator’sC onguration FileReference.
TheNative Thread Pool
OnWindows, the native thread pool (NativePool) is used internally by the server to execute
NSAPIfunctions that require a native thread for execution.
WebServer uses Netscape Portable Runtime (NSPR), which is an underlying portability layer
providingaccess to the host OS services. This layer provides abstractions for threads that are
notalways the same as those for the OS-provided threads. These non-native threads have lower
schedulingoverhead, so their use improves performance. However, these threads are sensitive
toblocking calls to the OS, such as I/O calls. To make it easier to write NSAPI extensions that
canmake use of blocking calls, the server keeps a pool of threads that safely support blocking
calls.These threads are usually native OS threads. During request processing, any NSAPI
functionthat is not marked as being safe for execution on a non-native thread is scheduled for
executionon one of the threads in the native thread pool.
Ifyou have written your own NSAPI plug-ins such as NameTrans,Service,orPathCheck
functions,these execute by default on a thread from the native thread pool. If your plug-in
makesuse of the NSAPI functions for I/O exclusively or does not use the NSAPI I/O functions
atall, then it can execute on a non-native thread. For this to happen, the function must be
loadedwith a NativeThread="no"option, indicating that it does not require a native thread.
Forexample, add the following to the load-modules Init line in the magnus.conf le:
UnderstandingThreads,Processes, and Connections
Chapter2 •Tuning Sun JavaSystem Web Server 43