Friday, February 29, 2008

Solaris Threading Model

I was looking for a detailed account of Solaris Kernel's architecture, specifically the threading model, and I found this book Solaris Internals. The one I have talks about Solaris 7's architecture. Now I believe that minute architectural details change frequently in Solaris because of the aggressive involvement of the OpenSolaris community. So, I might not be up to date with whatsoever I will discuss about here.

The basic execution unit in Solaris is a Process. Each process has its own Virtual Memory/Machine Environment. Now this environment is nothing more than a name given collectively to objects associated with a process, e.g. the address space, global variables, open files, accounting information etc. Such an environment isolates the process from other processes in the system which are apparently running concurrently.

By default, each process has atleast one thread of execution which is the default main thread. And, each Solaris process can have multiple threads, where all the threads share the same Virtual Memory environment of that process. The kernel uses time-slicing to allocate the CPU to these process threads, and once a process is taken off a CPU, its complete execution environment consisting of per thread items(program counter, stack, registers etc) are saved so that the thread can be resumed at some later time.

Now, in Solaris, Kernel threads execute on the CPU. Kernel threads are different from the User or Process threads in the sense that there creation and management is a responsibility of the kernel itself, and not some threading api. So now, we have discussed Kernel Threads and the thread contained by a process. Before discussing the threading model, it's better to talk about one more dimension of threads in Solaris. The Solaris kernel is multithreaded - "it is implemented with multiple threads of execution to allow concurrency across multiple processors". Such a kernel allows concurrent access to itself to improve performance on a multiprocessor system.

No comments: