1 / 80

Chapitre 10 Systèmes d’exploitation et synchronisation de processus

Chapitre 10 Systèmes d’exploitation et synchronisation de processus. Operating System model. Operating. Application. Hardware. System. Interactive usage. Batch Processing. Absolute Binary Loader. Central Memory. s3,t4. s3,t4. ABL. Command Interpreter. Central Memory. chess.

rimona
Download Presentation

Chapitre 10 Systèmes d’exploitation et synchronisation de processus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapitre 10 Systèmes d’exploitation et synchronisation de processus

  2. Operating System model Operating Application Hardware System

  3. Interactive usage

  4. Batch Processing

  5. Absolute Binary Loader Central Memory s3,t4 s3,t4 ABL

  6. Command Interpreter Central Memory chess s3,t4 Fmgr. Cmnd.Int. ABL

  7. Organizes data on disk Hides the details of physical files Offers standardized file organizations Sequential Random Access Indexed Sequential Maintains File Directories File Manager

  8. chess Cmnd.Int. Fmgr. ABL Command Interpreter

  9. Monoprogramming Process States task completed active I/O completion activation start I/O Blocked (busy wait) load waiting for cpu

  10. Control by Command Interpreter Cmnd Interpreter Program X Start User Pgm Return to CMND.INT

  11. Interrupt Handler Based System Command interpreter User program Interrupt handler File manager A.B.L.

  12. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  13. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  14. Fixed Partitions Physical Memory

  15. Automatic Relocation + Physical Memory Base Register

  16. Memory Segmentation Segment d Segment a Segment c Physical Memory Segment b

  17. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for efficient memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  18. Active Process Switch P1 P0 Save state into PCB0 Reload state from PCB1 Context switch overhead Save state into PCB1 Reload state from PCB0

  19. Process context Contents of registers Memory space & Memory Management tables One program can contain many processes No protection required Could share memory space Fast process switching Lightweight processes sharing memory space Threads Threads

  20. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  21. Manual selection (starting an application under Windows) Automatic selection based on priorities Based on the Round Robin algorithm Virtual memory reduces considerably the importance of job scheduling. Job SchedulerSelects the programs to be loaded in Central Memory

  22. Preempted tasks after t seconds Input queue Completed tasks Central memory New tasks Round Robin

  23. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  24. Multitasking Process States task completed active preemption start I/O activation load waiting for cpu I/O completion (interrupt) blocked swap out

  25. Non-preemptive Scheduling: Priorities are compared whenever the active program blocks itself a clock tick occurs (typically every 10 mS) Preemptive Scheduling Priorities are continuously compared. Process SchedulerAll programs have a priority and the one waiting with the highest priority becomes active.

  26. Process Priorities active -1 +1 p = p0 waiting for cpu blocked +1

  27. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  28. Program A Program B Program C Program D Output Spooling

  29. Efficient people can be working on several tasks in an interleaved fashion. Several programs kept in central memory Need for memory management Programs protected against each other Selection process for entering central memory CPU works alternatively for different programs Need for CPU scheduling I/O managed by Operating System (spooling) Communication facilities between programs Multitasking

  30. LOOP REPEAT UNTIL full; v := v + 1 END LOOP REPEAT UNTIL call; write(v); v := 0 END Concurrency& shared variablesExample : Rainfall recorder (1) P1 P2

  31. MOV v,D1 ADI D1,1 MOV D1,v MVI D2,0 MOV D2,v Concurrency& shared variablesExample : Rainfall recorder (2) v := v + 1 v := 0 t

  32. LOOP REPEAT UNTIL full; v := v + 1 END LOOP REPEAT UNTIL call; write(v); v := 0 END Critical SectionsExclusive access to shared variables P1 P2

  33. Mutual exclusion Only one process in its critical section Progress When processes compete to enter their C.S. no other processes can influence the choice the choice can not be postponed indefinitely Bounded waiting The number of times a process can enter its C.S. while another is waiting is bounded Critical Sections

  34. Software implementation: The Deckers Algorithm Hardware implementation On any computer: Test & Set bit Swap bit On monoprocessors: Disabling of interrupts Fundamental mechanism:The critical section

  35. Critical SectionsSimilar to single track railroad sections

  36. Critical SectionsWith boolean reservation

  37. … … … REPEAT UNTIL free; free := FALSE; (* use shared variable *) free := TRUE; … … … Critical SectionBoolean Reservation

  38. Critical SectionsWith turn indicator

  39. VAR turn : pturn,qturn; … … … REPEAT UNTIL pturn; (* use shared variable *) turn := qturn; … … … Critical SectionTurn Indicator

  40. Critical SectionsWith turn indicator

  41. VAR pneed,qneed : Boolean; … … … pneed := TRUE; REPEAT UNTIL NOT qneed; (* use shared variable *) pneed := FALSE; … … … Critical SectionDouble reservation

  42. VAR pneed,qneed:BOOLEAN;turn:pturn,qturn; … pneed := TRUE; WHILE qneed DO IF turn = qturn THEN pneed:=FALSE; REPEAT UNTIL turn = pturn; pneed := TRUE END END; (* use shared resource *) pneed := FALSE; turn := qturn; ... Deckers Algorithm

  43. Software implementation: The Deckers Algoritm Hardware implementation On any computer: Test & Set bit Swap bit On monoprocessors: Disabling of interrupts Fundamental mechanism:The critical section

  44. PROCEDURE TestAndSet (VAR X:BOOLEAN):BOOLEAN; VAR temp:BOOLEAN: BEGIN temp := X; X := TRUE; RETURN temp END TestAndSet; Test & SetTo be implemented in Hardware as one indivisible operation !!!

  45. Lock is a common BOOLEAN variable ... LOOP REPEAT UNTIL NOT TestAndSet(Lock); Critical Section Lock := FALSE; Remainder of loop END Critical Section with Test & Set No bounded waiting !

  46. PROCEDURE Swap (VAR X,Y:BOOLEAN); VAR temp:BOOLEAN; BEGIN temp := X; X := Y; Y := temp END Swap; SwapTo be implemented in Hardware as one indivisible operation !!!

  47. Lock is a common BOOLEAN variable, initially FALSE Each process has a local boolean variable Key ... LOOP Key := TRUE; REPEAT Swap(lock,key); UNTIL Key = FALSE; Critical Section Lock := FALSE; Remainder of loop END Critical Section with Swap No bounded waiting !

  48. Common variables: Waiting : ARRAY[0..n-1] OF BOOLEAN; Lock : BOOLEAN; i : 0 .. n-1; Variables specific for each process: Key : BOOLEAN; j : 0 .. n-1; Critical Sectionwith bounded waiting

  49. LOOP Trying to access the Critical Section; Critical Section; Rearranging priorities; Remainder Section END Critical Sectionwith bounded waiting Overall Outline of Process i

  50. Waiting[i] := TRUE; Key := TRUE; WHILE Waiting[i] AND Key DO Key := TestAndSet(Lock) END; Waiting[i] := FALSE; Critical Sectionwith bounded waiting Trying to access the Critical Section

More Related