




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、整理課件4.2nTo introduce the notion of a thread - a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems.nTo discuss the APls for Phtreads, Win32, and Java thread libraries.4.3nOverviewnMultithreading ModelsnThreading IssuesnPthreadsnWindows XP ThreadsnLinux Threads
2、nJava Threads4.4nA thread is a basic unit of CPU utilization; nIt comprises a thread ID, a program counter, a register set, and a stack.nIt shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals. 4.
3、54.6nResponsivenessnResource SharingnEconomynUtilization of MP Architectures4.7nUser threads are supported above the kernel and are managed without kernel support,Thread management done by user-level threads librarynkernel threads are supported and managed directly by the operating system.,Supported
4、 by the Kernel 4.8nUltimately, there must exist a relationship between user threads and kernel threads.nMany-to-OnenOne-to-OnenMany-to-Many4.9nMany user-level threads mapped to single kernel threadnExamples:lSolaris Green ThreadslGNU Portable ThreadsnThread management is done by the thread library i
5、n user space, so it is efficient;nbut the entire process will block if a thread makes a blocking system call.nbecause only one thread can access the kernel at a time, multiple threads are unable to run in parallel on multiprocessors.4.104.11nEach user-level thread maps to a kernel threadnIt provides
6、 more concurrency than the many-to-one model by allowing another thread to run when a thread makes a blocking system call; nit also allows multiple threads to run in parallel on multiprocessors. nThe only drawback is that creating a user thread requires creating the corresponding kernel thread, so r
7、estriction to the number of threads supported by the system is neccesarynExampleslWindows NT/XP/2000lLinuxlSolaris 9 and later4.124.13nAllows many user level threads to be mapped to many kernel threadsnAllows the operating system to create a sufficient number of kernel threadsnSolaris prior to versi
8、on 9nWindows NT/2000 with the ThreadFiber package4.144.15nSimilar to M:M, except that it allows a user thread to be bound to kernel threadnExampleslIRIXlHP-UXlTru64 UNIXlSolaris 8 and earlier4.164.17nprovides the programmer an API for creating and managing threads. ntwo primary ways of implementing
9、a thread library. lprovide a library entirely in user space with no kernel support. All code and data structures for the library exist in user space. This means that invoking a function in the library results in a local function call in user space and not a system call.limplement a kernel-level libr
10、ary supported directly by the operating system. In this case, code and data structures for the library exist in kernel space. Invoking a function in the API for the library typically results in a system call to the kernel.nThree main thread libraries are in use (1) POSIX Pthreads, (2) Win32, and (3)
11、 Java.4.18nA POSIX standard (IEEE 1003.1c) API for thread creation and synchronizationnAPI specifies behavior of the thread library, implementation is up to development of the librarynCommon in UNIX operating systems (Solaris, Linux, Mac OS X)4.19nImplements the one-to-one mappingnEach thread contai
12、nslA thread idlRegister setlSeparate user and kernel stackslPrivate data storage areanThe register set, stacks, and private storage area are known as the context of the threadsnThe primary data structures of a thread include:lETHREAD (executive thread block)lKTHREAD (kernel thread block)lTEB (thread
13、 environment block)4.20nJava threads are managed by the JVMnJava threads may be created by:lExtending Thread classlImplementing the Runnable interface4.214.22nSemantics of fork() and exec() system callsnThread cancellationnSignal handlingnThread poolsnThread specific datanScheduler activations4.23nD
14、oes fork() duplicate only the calling thread or all threads?4.24nTerminating a thread before it has finishednTwo general approaches:lAsynchronous cancellation terminates the target thread immediatelylDeferred cancellation allows the target thread to periodically check if it should be cancelled4.25nS
15、ignals are used in UNIX systems to notify a process that a particular event has occurrednA signal handler is used to process signalslSignal is generated by particular eventlSignal is delivered to a processlSignal is handlednOptions:lDeliver the signal to the thread to which the signal applieslDelive
16、r the signal to every thread in the processlDeliver the signal to certain threads in the process1.Assign a specific threa to receive all signals for the process4.26nCreate a number of threads in a pool where they await worknAdvantages:lUsually slightly faster to service a request with an existing th
17、read than create a new threadlAllows the number of threads in the application(s) to be bound to the size of the pool4.27nAllows each thread to have its own copy of datanUseful when you do not have control over the thread creation process (i.e., when using a thread pool)4.28nBoth M:M and Two-level models require communication to mai
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權】 ISO/IEC 15415:2024 EN Automatic identification and data capture techniques - Bar code symbol print quality test specification - Two-dimensional symbols
- 2025年度化工生產工廠技術許可合同協(xié)議
- 2025年城市管道天然氣項目建議書
- 設備管理科設備維護與更新計劃
- 提升倉庫服務質量的個人策略計劃
- 社區(qū)個人工作計劃改善社區(qū)供水設施
- 2025年特種大型鋁合金型材合作協(xié)議書
- 新聞媒體安全管理的必要性計劃
- 社團交流合作的網絡平臺計劃
- 2025年中大型重載軸承項目建議書
- 消防工程管理辦法附流程圖
- 幼兒園手工教學中教師指導行為研究-以自貢市幼兒園為例
- 初中物理實驗教學
- 雨水管道中粗砂回填
- 團意操作流程詳解課件
- SH/T 0356-1996燃料油
- 第1課中華優(yōu)秀傳統(tǒng)文化的內涵與特點課件(共28張PPT)
- 耳鼻咽喉頭頸外科學-鼻科癥狀學課件
- 輪胎使用日常說明
- 第8章 動車組空調裝置檢修動車組維護與檢修
- 《幼小銜接存在的問題及對策研究(論文)6400字》
評論
0/150
提交評論