SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
Multi-programming, Time-sharing
            & Real-time systems
• Under the supervisor control
• Input/output organisation
• Interrupt handling :
    o External interrupts (generally disconnected from current process)
          I/O interrupt (channel interrupt)
          Operator/user interrupt
          Clock interrupt (alarm clock, …)
          Processor interrupt
          Dis-functioning interrupt
    o Internal interrupts (directly dependent from the current process)
          Supervisor call
          Program errors
          Trapping or extra-code (micro-coding)
    First Year University Studies in Science. ULB . Computer Principles. Chapter 12   D. Bertrand 1
A simple mechanism
• The interrupt handling task is chosen by the supervisor
• No interrupt during the current interrupt handling
• Interrupts can be masked (to avoid uncontrolled sequence breaking)

        User process                                                                Interrupt routines
                                                                 Supervisor Process
              Masked                                              Interrupt calling       1st type
                                           interrupt
               event                                               analysis            interruption
                                                                  Interrupt
                                                                     end      end of       nd
           Unmasked                                                         handling 2 type
             event                                                                     interruption

                                                                                                  3rd type
          Interrupts                                                                 Interrupts interruption
            enabled                                                                   disabled
   First Year University Studies in Science. ULB . Computer Principles. Chapter 12                      D. Bertrand 2
Implementation
Registers :
• General interrupt mask (MM = 1 : enabled; MM = 0 disabled) MM 1
• Interrupt requests : array of bits     IR 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0
• Interrupt masks : array of bits       MS 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1
• Supervisor entry point for interrupt handling         ES: 32 bits
• PC saving memory zone                                 PS: 32 bits
Interrupts                                 Interrupts
enabled ?                                  masked ?
                                          yes      n                                  yes MM
               MM=1 ?                             ∑IRi .MSi ≠ 0?
                                                            i=1
                                                                                                 0; PS PC
                                                                                               PC ES

               no                                                 no

           I        [PC]
                                             • ES register can be replaced by an array
                                             • Each entry pointer to a specific service routine
          Execute I                          • Working registers saving (stack) !
    First Year University Studies in Science. ULB . Computer Principles. Chapter 12                         D. Bertrand 3
Multiprogramming
   Variation in speed of various modules of a computer                                                             dead times
            Task B : timing ≡ timing task A; independent I/O channels
 Task A
 input                        1                          2                             3               4               5
 channel 1
Processing                                         1                          2                    3               4                       5
output
channel 2                                                               1                      2               3                       4
 Task B
 input                                      1                          2                       3               4                       5
 channel 3
Processing             1                                         2                         3               4                  5
output
channel 4                                   1                                          2               3               4
                        1           2             3             4             5            6       7       8       9          10 time
                                                         ideal configuration !!!
     First Year University Studies in Science. ULB . Computer Principles. Chapter 12                                   D. Bertrand 4
Processes states
 • Concurrent processing : 3 states recognised by the scheduler
 • Working state : task using the control unit (computational state)
 • Waiting state : task waiting for an external resource
 • Ready state : task waiting for the control unit (main resource)
 • Scheduler serving the first ”ready” task
 • Priority system can be implemented
                                      system idle

Task A                    waiting ready                                     waiting              ready                ready

Task B      waiting ready                                     waiting                ready         waiting ready

Task C ready                                          waiting                            ready               waiting


                 1            2             3             4             5            6       7      8      9            10 time
   First Year University Studies in Science. ULB . Computer Principles. Chapter 12                                 D. Bertrand 5
Interrupt use
    • Task entering waiting state control given to supervisor :
        o Special interrupt : Supervisor call
        o System records the transition state (working waiting)
        o System records the restart condition (resource availability)
        o System chooses a task ready to work (priorities !)
        o Interrupt handling
        o State transition handling (scheduling work : next task to run)
                  switching time = supervision cost As small as possible !

 Task A                                                                         waiting                      ready
 Task B                  ready                                                                               waiting
 Task C                  ready                                                   ready
 Chan. 1                 ready                                                                       ready
interrupt                                     from task A                                 from chan. 1
                     1            2             3             4             5         6   7      8       9            10
    First Year University Studies in Science. ULB . Computer Principles. Chapter 12                           D. Bertrand 6time
Job classes and priorities
Two main categories of processes :
• CP-bound : computation in central memory; few I/O (number crunching)
• IO-bound : little computation; many I/O operations
• If only CP-bound processes : processor idle time very small
   no gain (even losses !) with multi-programming
• If only IO-bound processes : efficiency depends on synchronisation
            Mixture of CP-bound and I/O bound processes
Task A I/O ready                                               ready                           ready
                                                                                                        well-balanced
 Task A                                 waiting                                    waiting                 system
 Task B ready                                                  ready                           ready (use of clock inter.)

Task A I/O ready                                                                       ready
                                                                                                         Unbalanced
 Task A                                 waiting                                        ready               system
 Task B ready                                                                                        (optimised for proc.
                        1           2             3              4             5           6    7      not for periph.)
     First Year University Studies in Science. ULB . Computer Principles. Chapter 12              time       D. Bertrand 7
Spooling
• Sharing of ”sequential” peripherals (printers, magnetic tapes) difficult
• Not a problem for random access devices (different areas)
To solve the problem :
 Deferral output system                                                               I/O device spooling
• Output sent to a secondary storage device (magnetic disk, …)
• At the end of the task output put into an output queue
• When the device is ready : get one of the files of the output queue
 (special task : the output symbiont)
 Remarks
• Symbiont : part of system software but handled as a user process
• Queues can be built for different classes of peripherals (staging …)
• A class of devices can be handled by the same or different symbionts
• Same system can be applied to input queues
• Priorities can be defined at the level of the queues
    First Year University Studies in Science. ULB . Computer Principles. Chapter 12              D. Bertrand 8
Input                                                                                      Output
device                        Job evolution                                                device
                                          Process
                                                                                     Output
   Input                                                                           scheduler
   symbiont             working            Process                                   Output
                                          scheduler             ready
                                                                                   symbiont
            Job
         scheduler                                                          Termination
                                                    Resources
Input                                               scheduler                              Output
queue                  Request                                                             queue
                                            waiting


                  The operating system manages this evolution :
                         tables (status of the system and of its components)
                           o queue content
                           o processes status
                           o memory/peripherals occupation
                         choices algorithms (scheduling)
                         resource management (allocation)
  First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 9
Time sharing
              Multi-programmation                                      resource usage optimisation
                                                                      But …
                                                          Response time ?
  Response time = reading time + waiting time in input queue
                         + execution time
                 + waiting time in output queue + output time
execution time = Σ working times + Σ waiting times + Σ ready times

Reduction of processor idle time may be inefficient for response time !
Example :
• Two CP-bound tasks
• Different execution times (60 minutes ↔ 1 minute)
• Tasks are submitted at different times
   First Year University Studies in Science. ULB . Computer Principles. Chapter 12              D. Bertrand 10
1st case :
          Task A
          Task B                                                                    ready
              0           11                         60 61 time
• Looks like mono-programmation !
• But control unit is quite efficiently used
• User A happy !
• User B must wait 50 minutes for the execution of one minute job !
2nd case :
           Task A
           Task B
              0           11 12                            61 time
• Less efficient (more switching time)
• User B happy (response time reduced by 50)
• User A still happy (response time increased by 1.5 %)
• Average response time : 31 minutes (55 minutes in the first case)
  First Year University Studies in Science. ULB . Computer Principles. Chapter 12           D. Bertrand 11
Remarks
• Many short processes delay for medium and long processes
• Execution time is not always a priori known (errors, convergences, …)
                                                         Other technique :
• Put a working process in waiting state after a given time slice
• Activate a ready process
• Continue with another process …
 clock interrupt
                                                           Time-sharing :
Task A                                                              ready                              ready
Task B                   ready                                                         ready
Task C                                 ready                                                   ready
             1    2   3       4    5     6     7     8    9      10
                                                                    time
• All processes systematically put to working state (quasi-parallelism)
• Short processes quickly finished
• Medium and long processes not indefinitely waiting
     First Year University Studies in Science. ULB . Computer Principles. Chapter 12                   D. Bertrand 12
Comparison
    Multi-programmation                                                               Simultaneous management
            Time-sharing                                                              of several processes

                                  Multi-management systems
                                                       Main aim                           Method            Consequence

                                               optimisation of                         Management of
Multi-programmation                                                                                       quasi-parallelism
                                              control unit usage                      several processes

                                              Response time      Management of                             better use of
   Time-sharing
                                           optimisation (users) several processes                         active resources


           Some operating systems based on a compromise
    First Year University Studies in Science. ULB . Computer Principles. Chapter 12                           D. Bertrand 13
Interactive systems
• Task directives given interactively by the user
• Each user has its own access units (terminal : keyboard + screen)
• The user units do not need to be driven by a symbiont
• Commands generate interrupts and tasks state transition

                               Average response time = n . t
     n : number of users; t : average execution time of a command


• In general system in waiting state
• Each user get the impression to have his own computer



   First Year University Studies in Science. ULB . Computer Principles. Chapter 12   D. Bertrand 14
Real time systems
 Time-sharing systems with strict timing constraints
Systems requiring minimum response time :
• Process control in industry
• Probe control in space
• Electronic assistance systems in cars
• Flying systems in planes
• Data acquisition systems (physics, chemistry, …)

Systems requiring fast but not critical response time :
• Reservation systems (plane, trains, …)
• Automatic banking systems, …


 First Year University Studies in Science. ULB . Computer Principles. Chapter 12   D. Bertrand 15

Más contenido relacionado

Similar a Operating sistem

Similar a Operating sistem (7)

Atmel and pic microcontroller
Atmel and pic microcontrollerAtmel and pic microcontroller
Atmel and pic microcontroller
 
Ipc feb4
Ipc feb4Ipc feb4
Ipc feb4
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilog
 
Lect02
Lect02Lect02
Lect02
 
Indirect Communications (Concurrency)
Indirect Communications (Concurrency)Indirect Communications (Concurrency)
Indirect Communications (Concurrency)
 
1.ppt
1.ppt1.ppt
1.ppt
 

Operating sistem

  • 1. Multi-programming, Time-sharing & Real-time systems • Under the supervisor control • Input/output organisation • Interrupt handling : o External interrupts (generally disconnected from current process) I/O interrupt (channel interrupt) Operator/user interrupt Clock interrupt (alarm clock, …) Processor interrupt Dis-functioning interrupt o Internal interrupts (directly dependent from the current process) Supervisor call Program errors Trapping or extra-code (micro-coding) First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 1
  • 2. A simple mechanism • The interrupt handling task is chosen by the supervisor • No interrupt during the current interrupt handling • Interrupts can be masked (to avoid uncontrolled sequence breaking) User process Interrupt routines Supervisor Process Masked Interrupt calling 1st type interrupt event analysis interruption Interrupt end end of nd Unmasked handling 2 type event interruption 3rd type Interrupts Interrupts interruption enabled disabled First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 2
  • 3. Implementation Registers : • General interrupt mask (MM = 1 : enabled; MM = 0 disabled) MM 1 • Interrupt requests : array of bits IR 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0 • Interrupt masks : array of bits MS 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 • Supervisor entry point for interrupt handling ES: 32 bits • PC saving memory zone PS: 32 bits Interrupts Interrupts enabled ? masked ? yes n yes MM MM=1 ? ∑IRi .MSi ≠ 0? i=1 0; PS PC PC ES no no I [PC] • ES register can be replaced by an array • Each entry pointer to a specific service routine Execute I • Working registers saving (stack) ! First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 3
  • 4. Multiprogramming Variation in speed of various modules of a computer dead times Task B : timing ≡ timing task A; independent I/O channels Task A input 1 2 3 4 5 channel 1 Processing 1 2 3 4 5 output channel 2 1 2 3 4 Task B input 1 2 3 4 5 channel 3 Processing 1 2 3 4 5 output channel 4 1 2 3 4 1 2 3 4 5 6 7 8 9 10 time ideal configuration !!! First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 4
  • 5. Processes states • Concurrent processing : 3 states recognised by the scheduler • Working state : task using the control unit (computational state) • Waiting state : task waiting for an external resource • Ready state : task waiting for the control unit (main resource) • Scheduler serving the first ”ready” task • Priority system can be implemented system idle Task A waiting ready waiting ready ready Task B waiting ready waiting ready waiting ready Task C ready waiting ready waiting 1 2 3 4 5 6 7 8 9 10 time First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 5
  • 6. Interrupt use • Task entering waiting state control given to supervisor : o Special interrupt : Supervisor call o System records the transition state (working waiting) o System records the restart condition (resource availability) o System chooses a task ready to work (priorities !) o Interrupt handling o State transition handling (scheduling work : next task to run) switching time = supervision cost As small as possible ! Task A waiting ready Task B ready waiting Task C ready ready Chan. 1 ready ready interrupt from task A from chan. 1 1 2 3 4 5 6 7 8 9 10 First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 6time
  • 7. Job classes and priorities Two main categories of processes : • CP-bound : computation in central memory; few I/O (number crunching) • IO-bound : little computation; many I/O operations • If only CP-bound processes : processor idle time very small no gain (even losses !) with multi-programming • If only IO-bound processes : efficiency depends on synchronisation Mixture of CP-bound and I/O bound processes Task A I/O ready ready ready well-balanced Task A waiting waiting system Task B ready ready ready (use of clock inter.) Task A I/O ready ready Unbalanced Task A waiting ready system Task B ready (optimised for proc. 1 2 3 4 5 6 7 not for periph.) First Year University Studies in Science. ULB . Computer Principles. Chapter 12 time D. Bertrand 7
  • 8. Spooling • Sharing of ”sequential” peripherals (printers, magnetic tapes) difficult • Not a problem for random access devices (different areas) To solve the problem : Deferral output system I/O device spooling • Output sent to a secondary storage device (magnetic disk, …) • At the end of the task output put into an output queue • When the device is ready : get one of the files of the output queue (special task : the output symbiont) Remarks • Symbiont : part of system software but handled as a user process • Queues can be built for different classes of peripherals (staging …) • A class of devices can be handled by the same or different symbionts • Same system can be applied to input queues • Priorities can be defined at the level of the queues First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 8
  • 9. Input Output device Job evolution device Process Output Input scheduler symbiont working Process Output scheduler ready symbiont Job scheduler Termination Resources Input scheduler Output queue Request queue waiting The operating system manages this evolution : tables (status of the system and of its components) o queue content o processes status o memory/peripherals occupation choices algorithms (scheduling) resource management (allocation) First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 9
  • 10. Time sharing Multi-programmation resource usage optimisation But … Response time ? Response time = reading time + waiting time in input queue + execution time + waiting time in output queue + output time execution time = Σ working times + Σ waiting times + Σ ready times Reduction of processor idle time may be inefficient for response time ! Example : • Two CP-bound tasks • Different execution times (60 minutes ↔ 1 minute) • Tasks are submitted at different times First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 10
  • 11. 1st case : Task A Task B ready 0 11 60 61 time • Looks like mono-programmation ! • But control unit is quite efficiently used • User A happy ! • User B must wait 50 minutes for the execution of one minute job ! 2nd case : Task A Task B 0 11 12 61 time • Less efficient (more switching time) • User B happy (response time reduced by 50) • User A still happy (response time increased by 1.5 %) • Average response time : 31 minutes (55 minutes in the first case) First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 11
  • 12. Remarks • Many short processes delay for medium and long processes • Execution time is not always a priori known (errors, convergences, …) Other technique : • Put a working process in waiting state after a given time slice • Activate a ready process • Continue with another process … clock interrupt Time-sharing : Task A ready ready Task B ready ready Task C ready ready 1 2 3 4 5 6 7 8 9 10 time • All processes systematically put to working state (quasi-parallelism) • Short processes quickly finished • Medium and long processes not indefinitely waiting First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 12
  • 13. Comparison Multi-programmation Simultaneous management Time-sharing of several processes Multi-management systems Main aim Method Consequence optimisation of Management of Multi-programmation quasi-parallelism control unit usage several processes Response time Management of better use of Time-sharing optimisation (users) several processes active resources Some operating systems based on a compromise First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 13
  • 14. Interactive systems • Task directives given interactively by the user • Each user has its own access units (terminal : keyboard + screen) • The user units do not need to be driven by a symbiont • Commands generate interrupts and tasks state transition Average response time = n . t n : number of users; t : average execution time of a command • In general system in waiting state • Each user get the impression to have his own computer First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 14
  • 15. Real time systems Time-sharing systems with strict timing constraints Systems requiring minimum response time : • Process control in industry • Probe control in space • Electronic assistance systems in cars • Flying systems in planes • Data acquisition systems (physics, chemistry, …) Systems requiring fast but not critical response time : • Reservation systems (plane, trains, …) • Automatic banking systems, … First Year University Studies in Science. ULB . Computer Principles. Chapter 12 D. Bertrand 15