当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

Threads, SMP, and MicroKernels

资源类别:文库,文档格式:PPT,文档页数:41,文件大小:1.1MB,团购合买
点击下载完整版文档(PPT)

Threads. SMP and microkernels Processes and threads The two characteristics of a process unit of resource ownership virtual address space for the process image I/O channels. devices files unit of dispatching/scheduling/execution This is the execution path through one or more modules It is also the entity that is being scheduled and dispatched by the os a process may have many dispatching units. a unit of dispatching is commonly called a thread or lightweight process New notion of process: unit of resource ownershI

1 Threads, SMP, and MicroKernels • Processes and threads – The two characteristics of a process • unit of resource ownership – virtual address space for the process image – I/O channels, devices, files • unit of dispatching/scheduling/execution – This is the execution path through one or more modules. – It is also the entity that is being scheduled and dispatched by the OS. – A process may have many dispatching units. A unit of dispatching is commonly called a thread or lightweight process. – New notion of Process : unit of resource ownership

Threads Single process, single thread DOS Multiple processes, single thread per process UNIX One process, multiple threads Java run-time(actually not an Os) Multiple processes multiple threads per process Solaris. Windows 2000/XP Windows XP. mach. oS/2. Linux Multithreading a process unit of protection and unit of resource allocation )virtual address space, process image >)protected access to processors, interprocess communication (IPC), files. lo resources 2

2 Threads – Single process, single thread • DOS – Multiple processes, single thread per process • UNIX – One process, multiple threads • Java run-time (actually not an OS) – Multiple processes, multiple threads per process • Solaris, Windows 2000/XP, Windows XP, Mach, OS/2, Linux – Multithreading • a process – unit of protection and unit of resource allocation » virtual address space, process image » protected access to processors, interprocess communication (IPC), files, I/O resources

one process one thread multiple thread multiple processes multiple processes thread ocess multiple threads per process instruction trace Figure 4.1 Threads and Processes [andE971

3

Single-Threaded Multithreaded Process model Process model Thread Thread Thread Thread Thread Thread Pr User ocess Control Control Control Stack Block block Block Block Process User User sel sel Kernel Control: Stack Stack I Stack Address Stack Block S ace User Kernel Kernel i Kernel Address Stack Stack! Stack Space Figure 4.2 Single threaded and Multithreaded Process mode

4

Threads(cont Multithreading(cont Each thread has a thread execution state(running, ready, etc. a separate control block, with priority, some thread related state information, and saved processor context when not running (with program counter an execution stack some per-thread static storage for local variables access to the memory and resources of its process, shared with all other threads in the process A single application logically doing several functions especially in GUI systems Example application-a file server entertaining requests to create, open, read and write on files >>One thread per request Two threads cannot write on the same file at the same time

5 Threads (cont.) – Multithreading (cont.) • Each thread has – a thread execution state (running, ready, etc.) – a separate control block, with priority, some thread related state information, and saved processor context when not running (with program counter) – an execution stack – some per-thread static storage for local variables – access to the memory and resources of its process, shared with all other threads in the process, • A single application logically doing several functions, especially in GUI systems. – Example application -- a file server entertaining requests to create, open, read, and write on files. »One thread per request »Two threads cannot write on the same file at the same time

Benefits of threads less time to create(10 times )and terminate than doing the same thing to a process less time to switch between two threads within the same process parallel processing -multiple threads executing simultaneously on different processors communication between different executing modules within the same process In most Os, communication between independent processes requires the intervention of the kernel to provide protection and the mechanism needed for communication Because threads within the same task share memory and files, they can communicate with each other without invoking the kernel

6 Benefits of threads • less time to create (10 times) and terminate than doing the same thing to a process • less time to switch between two threads within the same process • parallel processing -- multiple threads executing simultaneously on different processors. • communication between different executing modules within the same process – In most OS, communication between independent processes requires the intervention of the kernel to provide protection and the mechanism needed for communication. – Because threads within the same task share memory and files, they can communicate with each other without invoking the kernel

RPC RPC Request Process 1 v Server (a) RPC Using Single Thread RPC Thread A (Process 1) Thread B(Process l Server (b)RPC Using One Thread per Server(on a uniprocessor) MZZ Blocked, waiting for response to RPC Blocked, waiting for processor, which is in use by Thread B Figure 4.3 Remote Procedure Call (RPC) Using Threads

7

Request Time quantum request complete expires Thread A(Process 1) Thread b (process 1) Thread C(Process 2) Time quantum exDI Process created 区× Blocked Ready Running Figure 4.4 Multithreading Example on a Uniprocessor

8

Screen-redrawthread Figure 4.5 Thread structure for adobe page maker

9

Example applications using threads Threads in a spreadsheet program One thread displays menus and read user input (foreground work) Another thread executes user commands and updates the spreadsheet (background work Adobe PageMaker Writing, design, and production tool for desktop publishing service thread event-handling thread screen-drawing thread When the event-handling thread(e.g, doing a large computation, etc. or the screen-drawing thread is busy, the service thread(e.g,, printing file importing, etc restricts user activity by disabling menu items and displaying a busy "cursor. The user is free to switch to other applications, or even kill the computation through the service thread

10 Example applications using threads • Threads in a spreadsheet program – One thread displays menus and read user input (foreground work). – Another thread executes user commands and updates the spreadsheet (background work). • Adobe PageMaker – Writing, design, and production tool for desktop publishing – service thread – event-handling thread – screen-drawing thread – When the event-handling thread (e.g., doing a large computation, etc.) or the screen-drawing thread is busy, the service thread (e.g., printing, file importing, etc.) restricts user activity by disabling menu items and displaying a “busy” cursor. The user is free to switch to other applications, or even kill the computation through the service thread

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共41页,可试读14页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有