中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)05 Threads

提纲 Overview Multithreading Models 3 Thread Libraries Threading Issues OS Examples for Thread 6 Thread Scheduling o OS Examples for Thread Scheduling 小结 口18走卡11月00 东香兰xanchen@ustc.edu.cn http:/staff..u011740i:Operating System操作系统原理斐 March29,20193/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 提纲 1 Overview 2 Multithreading Models 3 Thread Libraries 4 Threading Issues 5 OS Examples for Thread 6 Thread Scheduling OS Examples for Thread Scheduling 7 小结 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 3 / 44

Chapter Objectives Chapter Objectives 0 To introduce the notion of a thread-a fundamental unit of CPU utiliazation that forms the basis of multithreaded computer system. To discuss the APls for Pthreads,Win32,and JAVA thread libraries. 口1回年走1,2月Q0 东香兰xlanchen@ustc,edu.cn http:/staff..u011740i:Operating System操作系统原理 March29,20194/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter Objectives Chapter Objectives 1 To introduce the notion of a thread – a fundamental unit of CPU utiliazation that forms the basis of multithreaded computer system. 2 To discuss the APIs for Pthreads, Win32, and JAVA thread libraries. 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 4 / 44

Outline Overview 口1回年走1,2月Q0 东香兰xlanchen@ustc,edu.cn http:/staff..u011740i:Operating System操作系统原理 March29,20195/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Outline 1 Overview 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 5 / 44

Thread concept overview o A thread is a basic unit of CPU utilization; it comprises a thread ID,a program counter,a register set, and a stack. It shares with other threads belonging to the same process the code section,the data section,and other OS resources, such as open files,signals,etc o A traditional process has a single thread of control: heavyweight process. code data files code data files registers stack registers registers registers stack stack stack thread single-threaded process multithreaded process 陈适兰xlanchen@ustc.edu.cn http:/staf.u01174O1:Operating System操作系统原理 March 29,2019 6/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thread concept overview A thread is a basic unit of CPU utilization; ▶ it comprises a thread ID, a program counter, a register set, and a stack. ▶ It shares with other threads belonging to the same process the code section, the data section, and other OS resources, such as open files, signals, etc A traditional process has a single thread of control: heavyweight process. code data files registers stack single-threaded process thread code data files registers registers registers stack stack stack multithreaded process 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 6 / 44

Motivation o On modern desktop PC,many APPs are multithreaded. a seperate process with several threads Example 1:A web browser one for displaying images or text; another for retrieving data from network Example 2:A word processor one for displaying graphics; another for responding to keystrokes from the user; and a third for performing spelling grammer checking in the background Example 3:RPC servers for each message,a separate thread is used to service the message concurrency 口⊙生年12月0C 陈话兰xlanchen@ustc.edu.cn http/staff.u0117401 Operating System操作系统原理斐 March29,20197/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Motivation On modern desktop PC, many APPs are multithreaded. ▶ a seperate process with several threads ▶ Example 1: A web browser ⋆ one for displaying images or text; ⋆ another for retrieving data from network ▶ Example 2: A word processor ⋆ one for displaying graphics; ⋆ another for responding to keystrokes from the user; ⋆ and a third for performing spelling & grammer checking in the background ▶ Example 3: RPC servers ⋆ for each message, a separate thread is used to service the message ⋆ concurrency↑ 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 7 / 44

Motivation o Motivation In certain situations,a single application may be required to perform several similar tasks.Example:a web server Allow a server to service several concurrent requests.Example: an RPC server and Java's RMI systems The OS itself needs to perform some specific tasks in kernel, such as manging devices or interrupt handling. PARTICULAR,many OS systems are now multithreaded. Example:Solaris,Linux 口⊙卡生年12月00 陈适兰xlanchen@ustc.edu.cn http:/staf.u01174O1:Operating System操作系统原理 March29,20197/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Motivation Motivation ▶ In certain situations, a single application may be required to perform several similar tasks. Example: a web server ▶ Allow a server to service several concurrent requests. Example: an RPC server and Java’s RMI systems ▶ The OS itself needs to perform some specific tasks in kernel, such as manging devices or interrupt handling. ⋆ PARTICULAR, many OS systems are now multithreaded. ⋆ Example: Solaris, Linux 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 7 / 44

Benefits Example:an interactive application such as web browser, while one thread loading an image,another thread allowing user interaction Resource Sharing address space,memory,and other resources Economy Solaris: creating a process is about 30 times slower then creating a thread; context switching is about 5 times slower Utilization of MP Architectures parallelism and concurrency 口18,走卡11月00 陈话兰xlanchen@ustc.edu:cn http/staff.u0117401 Operating System操作系统原理斐 March29,20198/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Benefits 1 Responsiveness (响应度高) ▶ Example: an interactive application such as web browser, while one thread loading an image, another thread allowing user interaction 2 Resource Sharing ▶ address space, memory, and other resources 3 Economy ▶ Solaris: creating a process is about 30 times slower then creating a thread; context switching is about 5 times slower 4 Utilization of MP Architectures ▶ parallelism and concurrency ↑ 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 8 / 44

Outline 2Multithreading Models 口1⊙生年12月00 东香兰xanchen@ustc.edu.cn http:/staff..u011740i:Operating System操作系统原理斐 March29,20199/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Outline 2 Multithreading Models 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 9 / 44

Two Methods Two methods to support threads o User threads VS.Kernel threads User threads Thread management done by user-level threads library without kernel support Kernel may be multithreaded or not. Three primary thread libraries: POSIX Pthreads Win32 threads Java threads 口18,走卡11月00 东香兰xanchen@ustc.edu.cn http:/staff..u011740i:Operating System操作系统原理斐 March29,201910/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Two Methods Two methods to support threads User threads VS. Kernel threads 1 User threads ▶ Thread management done by user-level threads library without kernel support ⋆ Kernel may be multithreaded or not. ▶ Three primary thread libraries: 1 POSIX Pthreads 2 Win32 threads 3 Java threads 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 10 / 44

Two Methods Two methods to support threads o User threads VS.Kernel threads O Kernel Threads Supported by the Kernel,usually may be slower then user thread Examples Windows XP/2000 ★Solaris ★Linux Tru64 UNIX(formerly Digital UNIX) ★Mac OS X 口18走卡11月00 陈话兰xlanchen@ustc.edu:cn http/staff.u0117401 Operating System操作系统原理斐 March29,201910/44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Two Methods Two methods to support threads User threads VS. Kernel threads 2 Kernel Threads ▶ Supported by the Kernel, usually may be slower then user thread ▶ Examples ⋆ Windows XP/2000 ⋆ Solaris ⋆ Linux ⋆ Tru64 UNIX (formerly Digital UNIX) ⋆ Mac OS X 陈香兰 xlanchen@ustc.edu.cn http://staff.ustc.edu.cn/~xlanchen (Computer Application Laboratory, CS, USTC @ Hefei Embedded System Laboratory, CS, USTC @ Suzhou) 0117401: Operating System 操作系统原理与设计 March 29, 2019 10 / 44
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)04 CPU Scheduling.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)03 Processes.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)02 OS Structure.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)01 CS Structure.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)01 OS overview.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)课程简介(主讲:陈香兰).pdf
- 中国科学技术大学:《高级操作系统 Advanced Operating System》课程教学资源(PPT课件讲稿)第二章 分布式路由算法(2/2).ppt
- 中国科学技术大学:《高级操作系统 Advanced Operating System》课程教学资源(PPT课件讲稿)第二章 分布式路由算法主要内容(1/2,主讲:陈香兰).ppt
- 天津开放大学:《电子商务概论》课程教学资源(试卷习题)综合练习及答案.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)计算机网络应用基础练习_第三章.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)计算机安全练习_第七章.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)计算机基础知识练习_第一章.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)Word 2010文字处理系统练习_第四章.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)Windows 7操作系统及应用练习_第二章.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)PowerPoint 2010电子演示文稿系统练习_第六章.doc
- 国家开放大学:《计算机应用基础》课程教学资源(章节习题,含答案)Excel 2010电子表格系统练习_第五章.doc
- 国家开放大学:2016年秋季学期“开放专科”电子商务专业电子商务法律与法规期末试题(1月).pdf
- 国家开放大学:2016年秋季学期“开放专科”电子商务专业数据库基础期末试题(1月).pdf
- 国家开放大学:2016年秋季学期“开放专科”国际经济与贸易专业电子商务概论期末试题(开卷).pdf
- 国家开放大学:2016年春季学期“开放本科”计算机科学与技术专业软件工程期末试题(半开卷).pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)06 Process Synchronization.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)07 Deadlock.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)08 Main Memory.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)09 虚拟内存 Virtual Memory.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)10 文件系统接口 File System Interface.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)11 File 文件系统实现 File system implementation.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)12 外存 Mass Storage Systems.pdf
- 中国科学技术大学:《操作系统原理与设计 Operating System》课程教学资源(PPT课件讲稿)13 IO管理 IO systems.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)GNU开发工具链简介 GNU Tools(主讲:陈香兰).pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)基于x86的Linux启动代码分析.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)制作简单的Linux系统.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(PPT课件讲稿)内存寻址.ppt
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(PPT课件讲稿)Linux进程管理(1/3).ppt
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(PPT课件讲稿)Linux进程管理(2/3).ppt
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)中断和异常.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)系统调用.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(PPT课件讲稿)Linux进程管理(3/3).ppt
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)内存管理.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)Linux中的时钟和定时测量.pdf
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(课件讲义)Linux中的进程地址空间.pdf