提纲 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