Multithreading within Solaris: General and Java Specific
Unlike Linux, Solaris relies heavily on a multithreaded environment. Over the years, Solaris threads have evolved through two of the three typical models for thread implementation. We'll take a brief look at how previous versions of Solaris implemented threads, general concepts of multithreading and why it's good. We'll also look at some specific information on Java Multithreading concepts as Java is the language of choice for Solaris.
Previous Implementations
Previous releases of Solaris used a user-level threads library called "green threads". Because
the green threads library was user-level and the Solaris system could process only one green thread at a time, Solaris
handled the Java runtime as a many-to-one thread implementation. There were several problems with the green threads
environment:
Java apps could not inter-operate with existing MT applications in the Solaris environment.
Java threads could not run in parallel on multiprocessors.
A MT Java app could not harness true OS concurrency for faster apps on either uniprocessors or multiprocessors.
Since then, the green threads library has been replaced by the usage of native Solaris threads, which follow the many-to-many modle of threading. This enables true multiprocessing and enables Java apps to run thousands of threads concurrently.
Concepts of Multithreading
Multithreading has become an important programming paradigm for multiprocessing systems. Solaris would
argue with Linux coders that multithreading is essential for the smooth operation of a system. It
provides a powerful way for software developers to speed up apps and to, essentialy, make the system more
efficient. The most difficult roadblock for multithread developers is that many MT implementations are both
risky to use and ineffective because they're based on user-level libraries. These blocks
do not meet the modern worlds demand of mission-critical, object-oriented applications. Solaris
claims to "utilize the latest technology to provide the best performance, tools, support, and flexibility in
developing MT applications."
Benefits of Multithreading
Multithreading allows for the full exploitation of parallel hardware and the effective use of multiple processor
subsystems. MT is essential for the performance of symmetric multiprocessors but it also provides performance benefits on uniprocessor systems by improving the
overlap of operations such as I/O. Some key benefits of multithreading are apparent in:
Throughput - Threads let many concurrent compute operations and I/O requests within a single process.
Multiple processors - Threads allow for simultaneous and fully symmetric use of multiple processors.
Applications responsiveness - apps do not have to wait for the system if requests can be launched from its own thread.
Server responsiveness - large or complex requests don't block other requests for service.
System resource usage - Threads require less overhead to create, maintain, and manage than a traditional process.
Program structure - Threads can be used to simplify the structure of complex applications.
Communication - Thread synchronization functions can be used to enhance process-to-process communication.
Java Multithreading on Solaris
The Solaris MT kernel is one of the most important foundations of the Solaris operating environment. In a MT kernel,
each kernel thread is a single flow of control within the kernel's address space. On Solaris, java threads get mapped directly onto
operating system native threads. The Java thread model is a platform-specific abstraction on top of native threads. Java on Solaris, however,
leverages the multithreading capabilities of the kernel while also allowing developers to create powerful Java applications using
thousands of user-level threads for multiprocessor or uniprocessor systems through a very simple programming interface.
The Java on Solaris environment supports the many-to-many threads model. Two-level architecture separates the programming interface from the implementations by providing an intermediate layer, called light-weight processes. Individtual LWPs operate like virtual CPUs that execute code or system calls and are dispatched sepatately by the kernel. On Solaris, user-level threads are supported in the kernel by the kernel-schedulable LWPs. The Solaris two-level model delivers unprecedented high levels of flexibility for meeting many different programming requirements. The two-level model allows the kernel to accommodate the concurrency demands of all program types without blocking or otherwise restricting thread access to system services.