●●● ●●●● 4.1 Overview ●●●●● ●●● ●●●0● ●●●0 ● Benefits Responsiveness o Interactive application may continue running when part of it is blocked or is performing a lengthy operation ° Resource sharing o threads share the memory and the resource of process to which they belong To allow an application to have several different threads of activity within the same address space Economy e creation 30: 1, context switching 5: 1 o Utilization of multiprocessor architectures
7 4.1 Overview ⚫ Benefits ⚫ Responsiveness ⚫ Interactive application may continue running when part of it is blocked or is performing a lengthy operation ⚫ Resource sharing ⚫ Threads share the memory and the resource of process to which they belong ⚫ To allow an application to have several different threads of activity within the same address space ⚫ Economy ⚫ creation 30:1, context switching 5:1 ⚫ Utilization of multiprocessor architectures
●●● ●●●● 4. Threads ●●●●● ●●●● ●●●0● ●●●0 ●41 Overview e 4.2 Multithreading Models ●4.3 Thread libraries 4.4 Threading Issues 0 4.5 Operating System Examples
8 4. Threads ⚫ 4.1 Overview ⚫ 4.2 Multithreading Models ⚫ 4.3 Thread Libraries ⚫ 4.4 Threading Issues ⚫ 4.5 Operating System Examples
●●● ●●●● 4.2 Multithreading Models :99 ●●●0 User threads vs, Kernel threads ● User threads o Provided by a thread library at the user level e PosiX Pthreads. Mach c-threads, solaris ul-threads Kernel Threads Provided and managed by the os directly Linux Solaris2 Windows. BeOS Relationship between kernel threads and user threads Many-to-one model One-to-one model ●Many- to-many model
9 4.2 Multithreading Models ⚫ User Threads vs. Kernel Threads ⚫ User Threads ⚫ Provided by a thread library at the user level ⚫ POSIX Pthreads, Mach C-threads, Solaris UI-threads ⚫ Kernel Threads ⚫ Provided and managed by the OS directly ⚫ Linux, Solaris2, Windows, BeOS ⚫ Relationship between kernel threads and user threads ⚫ Many-to-one model ⚫ One-to-one model ⚫ Many-to-many model
●●● ●●●● 4.2 Multithreading Models :99 ●●●0 ● Many-to- one model Many user-level threads mapped to single kernel thread ser thread k刀+ kernel thread
10 4.2 Multithreading Models ⚫ Many-to-one model ⚫ Many user-level threads mapped to single kernel thread
●●● ●●●● 4.2 Multithreading Models : ●●●0 ● Threads management is done by the thread°° library in user space so it is efficient(no often to invoke system call) o The entire process will block if a thread makes blocking system call o Only one thread can access the kernel at a time, multiple threads are unable to run in parallel on multiprocessors ● Example: o Green threads for solaris2 o GNU Portable Threads
11 4.2 Multithreading Models ⚫ Threads management is done by the thread library in user space, so it is efficient (no often to invoke system call) ⚫ The entire process will block if a thread makes blocking system call ⚫ Only one thread can access the kernel at a time, multiple threads are unable to run in parallel on multiprocessors ⚫ Example: ⚫ Green threads for Solaris2. ⚫ GNU Portable Threads