Threads. SMP and microkernels Processes and threads The two characteristics of a process unit of resource ownership virtual address space for the process image I/O channels. devices files unit of dispatching/scheduling/execution This is the execution path through one or more modules It is also the entity that is being scheduled and dispatched by the os a process may have many dispatching units. a unit of dispatching is commonly called a thread or lightweight process New notion of process: unit of resource ownershI
1 Threads, SMP, and MicroKernels • Processes and threads – The two characteristics of a process • unit of resource ownership – virtual address space for the process image – I/O channels, devices, files • unit of dispatching/scheduling/execution – This is the execution path through one or more modules. – It is also the entity that is being scheduled and dispatched by the OS. – A process may have many dispatching units. A unit of dispatching is commonly called a thread or lightweight process. – New notion of Process : unit of resource ownership
Threads Single process, single thread DOS Multiple processes, single thread per process UNIX One process, multiple threads Java run-time(actually not an Os) Multiple processes multiple threads per process Solaris. Windows 2000/XP Windows XP. mach. oS/2. Linux Multithreading a process unit of protection and unit of resource allocation )virtual address space, process image >)protected access to processors, interprocess communication (IPC), files. lo resources 2
2 Threads – Single process, single thread • DOS – Multiple processes, single thread per process • UNIX – One process, multiple threads • Java run-time (actually not an OS) – Multiple processes, multiple threads per process • Solaris, Windows 2000/XP, Windows XP, Mach, OS/2, Linux – Multithreading • a process – unit of protection and unit of resource allocation » virtual address space, process image » protected access to processors, interprocess communication (IPC), files, I/O resources
one process one thread multiple thread multiple processes multiple processes thread ocess multiple threads per process instruction trace Figure 4.1 Threads and Processes [andE971
3
Single-Threaded Multithreaded Process model Process model Thread Thread Thread Thread Thread Thread Pr User ocess Control Control Control Stack Block block Block Block Process User User sel sel Kernel Control: Stack Stack I Stack Address Stack Block S ace User Kernel Kernel i Kernel Address Stack Stack! Stack Space Figure 4.2 Single threaded and Multithreaded Process mode
4
Threads(cont Multithreading(cont Each thread has a thread execution state(running, ready, etc. a separate control block, with priority, some thread related state information, and saved processor context when not running (with program counter an execution stack some per-thread static storage for local variables access to the memory and resources of its process, shared with all other threads in the process A single application logically doing several functions especially in GUI systems Example application-a file server entertaining requests to create, open, read and write on files >>One thread per request Two threads cannot write on the same file at the same time
5 Threads (cont.) – Multithreading (cont.) • Each thread has – a thread execution state (running, ready, etc.) – a separate control block, with priority, some thread related state information, and saved processor context when not running (with program counter) – an execution stack – some per-thread static storage for local variables – access to the memory and resources of its process, shared with all other threads in the process, • A single application logically doing several functions, especially in GUI systems. – Example application -- a file server entertaining requests to create, open, read, and write on files. »One thread per request »Two threads cannot write on the same file at the same time