parallelism
play

Parallelism ! Multiple processes concurrently Parallelism CPU1 - PDF document

Parallelism ! Multiple processes concurrently Parallelism CPU1 CPU1 CPU1 Pseudo- Process 1 CPU1 CPU1 CPU1 Operating Systems Process 2 Parallelism CPU1 Parallel Systems Process 1 True (Soon to be basic OS knowledge) CPU2 Process 2


  1. Parallelism ! Multiple processes concurrently Parallelism CPU1 CPU1 CPU1 Pseudo- Process 1 CPU1 CPU1 CPU1 Operating Systems Process 2 Parallelism CPU1 Parallel Systems Process 1 True (Soon to be basic OS knowledge) CPU2 Process 2 Parallel Hardware Two Operating Systems Registers Registers CPU1 CPU2 ! Divide memory in two ! Run an independent OS in each ! Each has it’s own processes ! Drawbacks Disk – Twice as much memory used for OS Memory Controller Disk – IPC tough – Who controls memory and disk? (convenient) • Symmetric Multi-Processors – Inefficient scheduling (efficient) • Increasingly common. • How to modify OS to handle new hardware? Sharing the Operating System Example Multiprocessor OSes Main Memory Processor 1 Processor 2 OS Code ! Almost all new OSes ! ! Unix Program – AT&T System V Program ! Designed from start Counter OS Common Data Counter – Sun Solaris – Windows NT P1’s OS Data Stack Pointer – HP Unix – Mach Stack Pointer P2’s OS Data – Digital Unix – IBM AIX P1’s OS Stack – SGI Irix P2’s OS Stack Race Shared? (see sample code) Conditions! stack process table current process device queues 1

  2. Threads (Lightweight Processes) ! Basic unit of CPU utilization Process – (“What?!” you say) Program A B C ! Own Counter – program counter (Threads) – register set text segment Threads – stack space A stack B stack C stack ! Shares Software Multi-Processors – code section A B C – data section data segment – OS resources “Multithreaded Program” Stack Example: A Threaded Spreadsheet A(int tmp) { Recalculate Display B(); Thread Thread A: tmp = 2 printf(tmp) Spreadsheet ; Data C } B() { Other B Data C(); A: tmp = 1 } Command Thread C() { A(2); } What Kinds of Programs to Thread? Thread Benefits ! “What about just using processes with ! Independent tasks shared memory?” – ex: debugger needs gui, program, perf monitor… – fine – especially when blocking for I/O! – debugging tougher (more thread tools) ! Single program, concurrent operation – processes slower – Servers N 30 times slower to create on Solaris N ex: file server, web server N slower to destroy – OS kernels N slower to context switch among N concurrent requests by multiple users -- no protection – processes eat up memory needed in kernel N few thousand processes not ok N few thousand threads ok 2

  3. Do they Work? Threads Standards ! POSIX (Pthreads ) ! Operating systems – Common API – Mach, Windows NT, Windows 95, Solaris, – Almost all Unix’s have thread library IRIX, AIX, OS/2, OSF/1 ! Win32 and OS/2 – Millions of (unforgiving) users ! NFS, SPECfp, SPECint – very different from POSIX, tough to port – commercial POSIX libraries for Win32 – OS/2 has POSIX option ! Solaris – started before POSIX standard – likely to be like POSIX 1 4 8 12 16 20 24 CPUs Levels of Threads User Level Thread Process A Process B Thread Kernel Thread 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend