Lecture Software construction - Lecture 17: Threads

Lecture Software construction - Lecture 17: Threads. The contents of this chapter include all of the following: Overview, multithreading models, threading issues, pthreads, windows XP threads, Linux threads, Java threads. | Software Construction Lecture 17 Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads Threads Single and Multithreaded Processes THREADS Benefits Responsiveness Resource Sharing Economy Utilization of MP Architectures THREADS User Threads Thread management done by user-level threads library Examples - POSIX Pthreads - Mach C-threads - Solaris threads THREADS Kernel Threads Supported by the Kernel Examples - Windows - Solaris - Tru64 UNIX - BeOS - Linux Scheduling THREADS Multithreading Models Many-to-One One-to-One THREADS How do user and kernel threads map into each other? Many-to-One Many user-level threads mapped to single kernel thread. Used on systems that do not support kernel threads. Examples: Solaris Green Threads GNU Portable Threads THREADS One-to-One Each user-level thread maps to kernel thread. Examples - Windows - Linux THREADS Threading Issues Semantics of fork() and . | Software Construction Lecture 17 Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads Threads Single and Multithreaded Processes THREADS Benefits Responsiveness Resource Sharing Economy Utilization of MP Architectures THREADS User Threads Thread management done by user-level threads library Examples - POSIX Pthreads - Mach C-threads - Solaris threads THREADS Kernel Threads Supported by the Kernel Examples - Windows - Solaris - Tru64 UNIX - BeOS - Linux Scheduling THREADS Multithreading Models Many-to-One One-to-One THREADS How do user and kernel threads map into each other? Many-to-One Many user-level threads mapped to single kernel thread. Used on systems that do not support kernel threads. Examples: Solaris Green Threads GNU Portable Threads THREADS One-to-One Each user-level thread maps to kernel thread. Examples - Windows - Linux THREADS Threading Issues Semantics of fork() and exec() system calls Does fork() duplicate only the calling thread or all threads? Thread cancellation Terminating a thread before it has finished Two general approaches: Asynchronous cancellation terminates the target thread immediately Deferred cancellation allows the target thread to periodically check if it should be cancelled THREADS Threading Issues Signal handling Signals are used in UNIX systems to notify a process that a particular event has occurred A signal handler is used to process signals Signal is generated by particular event Signal is delivered to a process Signal is handled Options: Deliver the signal to the thread to which the signal applies Deliver the signal to every thread in the process Deliver the signal to certain threads in the process Assign a specific thread to receive all signals for the process Thread pools Create a number of threads in a pool where they await work Advantages: Usually slightly faster to service a request with an existing thread than create a

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.