170 likes | 333 Views
Adapting UNIX For A Multiprocessor Environment Using Threads. Group A3 Jonathan Sippel Jahanzeb Faizan Ka Hou Wong. Introduction. In the 1980’s, systems were developed with multiple processors UNIX was an ideal operating system (O/S) to adapt for these systems
E N D
Adapting UNIX For A Multiprocessor Environment Using Threads Group A3 Jonathan Sippel Jahanzeb Faizan Ka Hou Wong
Introduction • In the 1980’s, systems were developed with multiple processors • UNIX was an ideal operating system (O/S) to adapt for these systems • Early implementations of multiprocessor UNIX were asymmetric • Scalability declined rapidly as additional processors were added
The UNIX Process Model • UNIX is a multitasking environment i.e. several processes are active in the system concurrently • Processes contend for resources, with the UNIX kernel acting as a resource manager • Only one process can run at a time on the processor
Limitations of the UNIX Process Model • Many applications need to: • Run independent tasks concurrently • Share a common address space • Share other resources • On traditional UNIX systems these applications must spawn multiple processes • A process cannot take advantage of a multiprocessor architecture because only one processor can be used at a time
Improving the UNIX Process Model • A traditional process has a single thread of control • A multithreaded process is associated with one or more threads of control • Threads of control (threads) share the process instructions and most of the process data • Each thread executes independently
P P CPU P P P time process P address space Improving the UNIX Process Model (cont’d)
CPU time thread address space Improving the UNIX Process Model (cont’d)
CPU CPU blocked CPU CPU blocked CPU time address space thread Improving the UNIX Process Model (cont’d)
Multithreaded Systems • Parallelism – the actual degree of parallel execution achieved by an application. Limited by the number of available processors • Concurrency – the maximum parallelism an application can achieve using an unlimited number of processors
Multithreaded Systems (cont’d) • The kernel provides system concurrency by recognizing multiple threads of control within a process • User-level thread libraries are used by applications to provide user concurrency • Each concurrency model is of limited value by itself • Many systems combine system and user concurrency to implement a dual concurrency model
Kernel Threads • Do not need to be associated with a user process • Can be independently scheduled and use the standard synchronization mechanisms of the kernel • Used for performing synchronous I/O operations and to handle interrupts
Lightweight Processes • A lightweight process (LWP) is a kernel-supported user thread • A system must support a kernel thread before it can support LWPs. • LWPs are independently scheduled and share the process address space • True parallelism exists on a multiprocessor system since each LWP can be scheduled to run on a separate processor
K K K K K K K K K P P L L L L L thread scheduler CPU CPU CPU P process kernel thread L lightweight process address space Lightweight Processes (cont’d)
User Threads • Thread abstraction can be provided entirely at the user level by library packages (e.g. POSIX p-thread and Mach c-thread libraries) • The libraries provide all the functions for creating, synchronizing, scheduling and managing threads • No special assistance is required from the kernel
U U U U U U U U P P P CPU CPU user thread address space process P User Threads (cont’d)
U U U U U U U U U L L L L L CPU CPU user thread address space L lightweight process User Threads (cont’d)
Summary • Redesigning UNIX around threads has made it a more efficient O/S • Applications that need to perform several largely independent tasks concurrently, but must share a common address space, can now take advantage of UNIX thread facilities • By having multiple threads of control, UNIX applications can take advantage of the parallelism that a multiprocessor architecture provides