中国高校课件下载中心 》 教学资源 》 大学文库

《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 4 Threads

文档信息
资源类别:文库
文档格式:PDF
文档页数:60
文件大小:735.55KB
团购合买:点击进入团购
内容简介
• Thread Concepts – Why use threads – Structure in Memory – Benefits and Challenges – Thread Models • Programming – Basic Programming: Pthreads Library – Implicit Threading: Thread Pools & OpenMP
刷新页面文档预览

Operating SystemsCh4 Threads1

Operating Systems 1 Ch4 Threads

Chapter 4:Threads· Thread Concepts- Why use threads-StructureinMemory-BenefitsandChallenges- Thread ModelsProgramming-Basic Programming:Pthreads Library-Implicit Threading:ThreadPools&OpenMP2

Chapter 4: Threads • Thread Concepts – Why use threads – Structure in Memory – Benefits and Challenges – Thread Models • Programming – Basic Programming: Pthreads Library – Implicit Threading: Thread Pools & OpenMP 2

Multi-threading- Motivation3

3 Multi-threading - Motivation

Motivation-Application Side· Most software applications are multithreaded, eachapplication is implemented as a process withseveral threads of control-Webbrowser: displays images, retrieve data from network-Wordprocessor? display graphics, respond to keystrokes, spelling & grammarchecking4

Motivation - Application Side • Most software applications are multithreaded, each application is implemented as a process with several threads of control – Web browser • displays images, retrieve data from network – Word processor • display graphics, respond to keystrokes, spelling & grammar checking 4

Motivation-ApplicationSide: Most software applications are multithreaded-Webbrowser-Wordprocessor- Similar tasks in a single application (web server)·Acceptclientrequests,servicethereguests·Usuallyservethousandsof clients(2) create new(1) requestthreadto servicethe requestclientthreadserver(3) resume listeningforadditionalclient requests5

Motivation - Application Side • Most software applications are multithreaded – Web browser – Word processor – Similar tasks in a single application (web server) • Accept client requests, service the requests • Usually serve thousands of clients 5

Motivation-ApplicationSide Why not create a process for each task?-Processcreationis: Heavy-weighted·Resourceintensive Still remember what kinds of data are included in aprocess...- Text, data, stack, heap in user-space memory-PcBinkernel-spacememoryMany of the data can be shared between multipletasks within an application6

Motivation – Application Side • Why not create a process for each task? – Process creation is • Heavy-weighted • Resource intensive • Still remember what kinds of data are included in a process. – Text, data, stack, heap in user-space memory – PCB in kernel-space memory • Many of the data can be shared between multiple tasks within an application 6

Motivation-SystemSide? Modern computers usually contain multicores- But, each processor can run only one process at a time- CPU is not fully utilized· How to improve the efficiency?-Assign one task to each core- Real parallelism (not just concurrency with interleavingonsingle-coresystem)7

Motivation – System Side • Modern computers usually contain multicores – But, each processor can run only one process at a time – CPU is not fully utilized • How to improve the efficiency? – Assign one task to each core – Real parallelism (not just concurrency with interleaving on single-core system) 7

Concurrencyvs.ParallelismConcurrent execution on single-core system:T1T2T3T4T1T3T4T2T1single coretimeParallel execution on a multi-core system:T1T3T3T1T1core1T4T4T2T2T2core2time8

Concurrency vs. Parallelism 8 Concurrent execution on single-core system: Parallel execution on a multi-core system:

Multi-threading- Motivation- Thread Concept

9 Multi-threading - Motivation - Thread Concept

High-level ldeafilesdatafilescodedatacodestackregistersregistersregistersregistersstackstackstackthreadthreadmultithreadedprocesssingle-threadedprocess10

High-level Idea 10

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档