操作系统LEC4-多线程技术

上传人:w****i 文档编号:92792763 上传时间:2019-07-12 格式:PPTX 页数:38 大小:1.57MB
返回 下载 相关 举报
操作系统LEC4-多线程技术_第1页
第1页 / 共38页
操作系统LEC4-多线程技术_第2页
第2页 / 共38页
操作系统LEC4-多线程技术_第3页
第3页 / 共38页
操作系统LEC4-多线程技术_第4页
第4页 / 共38页
操作系统LEC4-多线程技术_第5页
第5页 / 共38页
点击查看更多>>
资源描述

《操作系统LEC4-多线程技术》由会员分享,可在线阅读,更多相关《操作系统LEC4-多线程技术(38页珍藏版)》请在金锄头文库上搜索。

1、Operating System,Lecture Four Multi-Threads School of Software Nanjing University,本主题教学目标,掌握多线程环境下进程和线程的概念 掌握线程的三种实现模型 了解并行处理环境,掌握SMP 了解Windows的进程和线程管理 掌握Solaris的进程和线程管理模型,Multi-Threads,Processes and Threads Symmetric Multiprocessing(SMP) Windows Threads and SMP Management Solaris Thread and SMP Man

2、agement,Process,Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution- follows an execution path that may be interleaved with other processes These two characteristics are treated independently by the operating system,Process,DataBase Manage

3、ment System: I/O Dispatching is referred to as a thread Resource of ownership is referred to as a process or task,Multithreading,Operating system supports multiple threads of execution within a single process MS-DOS supports a single thread UNIX supports multiple user processes but only supports one

4、 thread per process Windows 2000, Solaris, Linux, Mach, and OS/2 support multiple threads,Process,Have a virtual address space which holds the process image Protected access to processors, other processes, files, and I/O resources,Thread,An execution state (running, ready, etc.) Saved thread context

5、 when not running Has an execution stack Some per-thread static storage for local variables Access to the memory and resources of its process all threads of a process share this,Benefits of Threads,Takes less time to create a new thread than a process Less time to terminate a thread than a process L

6、ess time to switch between two threads within the same process Since threads within the same process share memory and files, they can communicate with each other without invoking the kernel,Threads,Suspending a process involves suspending all threads of the process since all threads share the same a

7、ddress space Termination of a process, terminates all threads within the process,Thread States,States associated with a change in thread state Spawn Spawn another thread Block Unblock Finish Deallocate register context and stacks,Remote Procedure Call Using Threads,Remote Procedure Call Using Thread

8、s,User-Level Threads,All thread management is done by the application The kernel is not aware of the existence of threads API: a program library is used to manage ULT, witch is separated from OS kernel Jacketing Blocking a thread will block a process Modify OS kernel, when a thread becomes block sta

9、te by executing a system call, system call can pass the control to another thread in this process instead switching the process,Kernel-Level Threads,W2K, Linux, and OS/2 are examples of this approach Kernel maintains all information for the process and the threads Scheduling in OS is done on a threa

10、d basis OS provides a KLT API to programmers OS can be realized by multi-thread technology,ULT and KLT,ULT switching is done in user address space, this saves the overhead of mode switch Scheduling of ULT can be application specific. One application can benefit through tailored scheduling algorithm

11、ULTs can run on any OS In a typical OS, when a thread executes a system call, the thread blocked will cause the process blocked A pure ULT application can not take advantage of multiprocessing,Combined Approaches,Example is Solaris Thread creation done in the user space Bulk of scheduling and synchr

12、onization of threads done in the user space ULTs can be mapped onto KLTs. KLTs can run parallel on multi processors. The programmer may adjust the number of KLTs to achieve the best overall results If properly deigned, this approach should combine the advantages of the pure ULT and KLT approaches wh

13、ile minimizing the disadvantages,Multi-Threads,Processes and Threads Symmetric Multiprocessing(SMP) Windows Threads and SMP Management Solaris Thread and SMP Management,Categories of Computer Systems,Single Instruction Single Data (SISD) single processor executes a single instruction stream to opera

14、te on data stored in a single memory Single Instruction Multiple Data (SIMD) each instruction is executed on a different set of data by the different processors,Categories of Computer Systems,Multiple Instruction Single Data (MISD) a sequence of data is transmitted to a set of processors, each of wh

15、ich executes a different instruction sequence. Never implemented Multiple Instruction Multiple Data (MIMD) a set of processors simultaneously execute different instruction sequences on different data sets,Symmetric Multiprocessing,Kernel can execute on any processor Typically each processor does sel

16、f-scheduling form the pool of available process or threads,Multi-Threads,Processes and Threads Symmetric Multiprocessing(SMP) Windows Threads and SMP Management Solaris Thread and SMP Management,Windows 2000 Process Object,Windows 2000 Thread Object,Windows 2000 Thread States,Ready Standby Running Waiting Transition Terminated,Multi-Threads,Processes and Threads Symmetric Multiprocessing(SMP) Windows Threads and SMP Management Solaris Thread and SMP Management,Solaris,Process includes the user

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号