Az előadás letöltése folymat van. Kérjük, várjon

Az előadás letöltése folymat van. Kérjük, várjon

P árhuzamos és Elosztott Rendszerek Operációs Rendszerei Rövid András

Hasonló előadás


Az előadások a következő témára: "P árhuzamos és Elosztott Rendszerek Operációs Rendszerei Rövid András"— Előadás másolata:

1 P árhuzamos és Elosztott Rendszerek Operációs Rendszerei Rövid András rovid.andras@nik.bmf.hu

2 Tartalom Hardver áttekintés Intrukciók feldolgozása (Pipelining) Többmagos architektúrák Hyperthreading technológia Operációs rendszer szerepe Operációs rendszerek struktúrája Rendszerhívások Virtuális gépek Többprocesszoros OS típusok

3

4

5 Hardver áttekintés A processzor-ciklus A következő instrukció betöltése a memóriából (FETCH) Dekódolás (pl. a 10110010… bináris érték milyen instrukciót takar?) – (DECODE) Futtatás (EXECUTE)

6 Minden CPU-nak saját instrukciókészlete van (pl. Pentium CPU-ra írt program nem futtatható SPARC CPU-n) Regiszterkészlet (általános és speciális felhasználású regiszterek) Program counter (PC), Stack pointer (SP), stb. Hardver áttekintés

7 CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 MEMORY MOV R1, #10 MOV R2, #20 MOV R3, #2 MUL R4, R2, R3 ADD R5, R1, R4 BREAK include int main( ) { int a=10; int b=20; int c; c=a+b*2; return 0; }

8 CPU Control Unit CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 110A DECODE 0001 Opcode MOV 0001 Register 0110 Data1 0100 Data2 PC = 1000 CPUMEMORY

9 RegiszterÉrték R0 R100001010 R2 R3 R4 R5 R6 R7 110A110A 10 decimálisan 0001 R1 0001 MOV PC = 1000 CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 MEMÓRIA Dekódolás Végrehajtás

10 RegiszterÉrték R0 R100001010 R200010100 R3 R4 R5 R6 R7 12141214 20 decimálisan 0010 R2 0001 MOV Dekódolás Végrehajtás CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 MEMÓRIA PC = 1002

11 RegiszterÉrték R0 R100001010 R200010100 R300000010 R4 R5 R6 R7 13021302 2 decimálisan 0011 R3 0001 MOV Dekódolás Végrehajtás CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 MEMÓRIA PC = 1004

12 RegiszterÉrték R0 R100001010 R200010100 R300000010 R400101000 R5 R6 R7 34233423 0100 R4 0011 MUL Dekódolás Végrehajtás CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 MEMÓRIA 00100011 R2R3 MUL ALU PC = 1006

13 RegiszterÉrték R0 R100001010 R200010100 R300000010 R400101000 R500110010 R6 R7 35233523 0101 R5 0010 ADD Dekódolás Végrehajtás CímÉrték ============== 1000110A 1002 1214 1004 1302 1006 3423 1008 2514 100A 0000 MEMÓRIA 00010100 R1R4 ADD ALU PC = 1008

14 Szuperszkalár CPU Fetch unit Fetch unit Execute unit Execute unit Execute unit Puffer Decode unit Decode unit

15 Multicore Core 1Core 2 Core 3Core 4 L2 cache L1 cache Core 1 L1 cache L2 Core 1 L2 Core 1 L2 Core 1 L2 Megosztott L2 cache Különálló L2 cachek

16

17 Hyperthreading

18 Erőforrás kihasználtság

19 Operációs rendszer szerepe User Interface Program (Shell, GUI) OS HW Web kliens E-mail kliens Egyéb alkalmazás User mode Kernel mode Software Hardware

20 Módok User mód Az instrukciók csak egy részhalmaza érhető el Kernel mód Teljes hozzáférés a hardverhez A teljes instrukciókészlet elérhető (bármelyik instrukció futtatható)

21 Operációs rendszerek struktúrája Főbb struktúrák: Monolitikus Rétegezett Mikorkernelek Kliens-Szerver model Virtuális gépek

22 Monolitikus Rendszerek Application Programs Application Programs System Services Hardware User Mode Kernel Mode Az OS teljes egészében kernel módban fut A rendszer egybe linkelt eljárások gyűjteménye, azaz egyetlen futtatható bináris programként van jelen

23 Rétegezett Rendszerek Application Programs Application Programs System Services User Mode Kernel Mode Memory & I/O Device Mgmt Hardware Process Schedule Application Programs Application Programs

24 Microkernelek A modern oprendszerek ebbe a kategóriába tartoznak

25 Kliens-Szerver Model Client Application Client Application Thread lib. Thread lib. File Server File Server Network Server Network Server Display Server Display Server Microkernel Hardware User Kernel Send Reply A kommunikáció a kliens és a szerver között üzenet- küldéssel valósul meg. A folyamatok két osztályát különböztetjük itt meg: 1.Kliensek melyek a szolgáltatást igénybe veszik 2.Szerverek melyek a szolgáltatást nyújtják

26 Rendszerhívások Interface a felhasználói programok és az OS között Amikor egy user módban futó folyamat az OS valamelyik szolgáltatását akarja igénybe venni (pl. olvasás fájlból) egy ún. „trap” instrukciót kell végrehajtania, amivel átadja az OS-nek az irányítást. Az OS az átadott paramtérek alapján kideríti, milyen szolgáltatásról van szó Ezután végrehajtja a rendszerhívást Majd visszaadja az irányítást a rendszerhívást követő instrukció címére. count = read(fd, buffer, nbytes)

27 Increment SP Call read Push fd Push &buffer Push nbytes Return to caller Trap to kernel Put code for read in register System call nr. examining Running Sys. call handler 1 2 3 4 5 6 78 9 10 Rendszerhívás folyamata

28 Virtuális gépek HW Hypervisor WindowsLinux… … App-1 App-2 App-3App-1 App-2 App-3 Amikor a virtualis gépen futó OS privilegizált instrukciót futtat a hypervisor közvetít

29 HW Hypervisor Trap on priviledged instructions Guest OS User Processes Virtual machine Virtual user mode Virtual kernel mode kernel mode Virtuális kernel mód

30 Virtuális gépek

31 8/20/201431 Multiprocessor OS Types (1) Each CPU has its own OS bus Characteristics: share single copy of OS code partition multiprocessor memory among four CPUs sharing of set of disks and other I/O devices Design aspects: when a process makes a system call, system call is handled by its own CPU no sharing of processes – consequence: no load balancing on CPUs no sharing of pages – consequence: no load balancing on memory independent buffer caching of disk blocks problem: no load balancing on CPU, memory and inconsistencies

32 8/20/201432 Multiprocessor OS Types (2) Master-Slave Multiprocessors Characteristics: one copy of OS and its tables are present on one CPU and not the others all system calls are redirected to the one CPU for processing CPU with OS is called master, all other CPUs running applications are called slaves Design aspects: there is only data structure that keeps track of ready processes – good for load balancing pages can be allocated among all processes dynamically there is only one buffer cache so inconsistencies never occur What are the problems with this OS type? bus

33 8/20/201433 Multiprocessor OS Types (3) Symmetric Multiprocessors Characteristics: eliminates the master/slave asymmetry there is one copy of OS, but any CPU can run it when a system call is made, the CPU traps to the kernel, which processes the system call Design aspects: dynamic balance of processes and memory, since there is only one set of OS tables eliminates master as a bottleneck What are the problems with this OS Type? bus

34 Parallel Programming Parallelization Idea Parallelization is “easy” if processing can be cleanly split into n units:

35 Parallelization Idea (2) In a parallel computation, we would like to have as many threads as we have processors. e.g., a four-processor computer would be able to run four threads at the same time.

36 Parallelization Idea (3)

37 Parallelization Idea (4)

38 Parallelization Pitfalls But this model is too simple! How do we assign work units to worker threads? What if we have more work units than threads? How do we aggregate the results at the end? How do we know all the workers have finished? What if the work cannot be divided into completely separate tasks?

39 Parallelization Pitfalls (2) Each of these problems represents a point at which multiple threads must communicate with one another, or access a shared resource. Golden rule: Any memory that can be used by multiple threads must have an associated synchronization system!

40 The Moral: Be Careful! Synchronization is hard – Need to consider all possible shared state – Must keep locks organized and use them consistently and correctly Knowing there are bugs may be tricky; fixing them can be even worse! Keeping shared state to a minimum reduces total system complexity

41 8/20/201441 Multiprocessor Synchronization (1) To ensure atomic execution of TSL, we have to be able to lock the bus


Letölteni ppt "P árhuzamos és Elosztott Rendszerek Operációs Rendszerei Rövid András"

Hasonló előadás


Google Hirdetések