Date post: | 21-Oct-2014 |
Category: |
Documents |
View: | 180 times |
Download: | 0 times |
D. Bertrand 1First Year University Studies in Science. ULB . Computer Principles. Chapter 12
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)
D. Bertrand 2First Year University Studies in Science. ULB . Computer Principles. Chapter 12
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)
Maskedevent
Unmaskedevent
User process
InterruptanalysisInterrupt
end
Supervisor1st type
interruption
2nd typeinterruption
3rd typeinterruption
Interrupt routinesin
terr
upt
Processcalling
end ofhandling
Interruptsenabled
Interruptsdisabled
D. Bertrand 3First Year University Studies in Science. ULB . Computer Principles. Chapter 12
ImplementationRegisters :• General interrupt mask (MM = 1 : enabled; MM = 0 disabled)
ES: 32 bitsPS: 32 bits
• Interrupt requests : array of bits• Interrupt masks : array of bits• Supervisor entry point for interrupt handling• PC saving memory zone
1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0IR0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1MS
1MM
Execute I
MM 0; PS PCPC ES
yes
no
I [PC]
no
≠∑ 0?n
i ii=1
.MIR Syes
Interruptsmasked ?
MM=1 ?
Interruptsenabled ?
• ES register can be replaced by an array• Each entry pointer to a specific service routine• Working registers saving (stack) !
D. Bertrand 4First Year University Studies in Science. ULB . Computer Principles. Chapter 12
1 32 4 108765 9
MultiprogrammingVariation in speed of various modules of a computer dead times
time
432
2
1 5
5
4
4
3
3
2
Task A1input
channel 1
1outputchannel 2
Processing
43
5
5
4
4
3
3
1inputchannel 3
2
1Processing
Task B
Task B : timing ≡ timing task A; independent I/O channels
ideal configuration !!!
outputchannel 4 1
2
2
D. Bertrand 5First Year University Studies in Science. ULB . Computer Principles. Chapter 12
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)
1 32 4 108765 9 time
waiting
ready
waitingready ready ready
waiting ready
waiting
waiting readyready
ready
waiting
waiting
Task A
Task B
Task C
• Scheduler serving the first ”ready” task• Priority system can be implemented
system idle
D. Bertrand 6First Year University Studies in Science. ULB . Computer Principles. Chapter 12
Interrupt use• Task entering waiting state control given to supervisor :
o Special interrupt : Supervisor callo System records the transition state (working waiting)o System records the restart condition (resource availability)o System chooses a task ready to work (priorities !)
1 32 4 108765 9 time
ready
waiting ready
waiting
from task A
Task A
Task BTask C ready ready
ready ready
from chan. 1
Chan. 1interrupt
switching time = supervision cost As small as possible !
o Interrupt handlingo State transition handling (scheduling work : next task to run)
D. Bertrand 7First Year University Studies in Science. ULB . Computer Principles. Chapter 12
Job classes and prioritiesTwo 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
time
waitingTask ATask A I/O
Task Bwaiting
ready
ready
ready
ready
ready
ready
1 32 4 765
Task ATask A I/O
Task Bwaiting
ready
ready
ready
ready
Mixture of CP-bound and I/O bound processes
well-balancedsystem
(use of clock inter.)
Unbalancedsystem
(optimised for proc.not for periph.)
D. Bertrand 8First Year University Studies in Science. ULB . Computer Principles. Chapter 12
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• 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
I/O device spooling
D. Bertrand 9First Year University Studies in Science. ULB . Computer Principles. Chapter 12
Job evolution
waiting
working ready
Inputdevice
Outputdevice
Inputqueue
Outputqueue
Processscheduler
Resourcesscheduler
Request
Inputsymbiont
Jobscheduler
Outputsymbiont
Outputscheduler
Termination
Process
The operating system manages this evolution : tables (status of the system and of its components)
o queue contento processes statuso memory/peripherals occupation
choices algorithms (scheduling) resource management (allocation)
D. Bertrand 10First Year University Studies in Science. ULB . Computer Principles. Chapter 12
Time sharingMulti-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
D. Bertrand 11First Year University Studies in Science. ULB . Computer Principles. Chapter 12
time6011
ready
61
time11 12 61
0
Task ATask B
0
Task ATask B
• 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 !
1st case :
2nd case :
• 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)
D. Bertrand 12First Year University Studies in Science. ULB . Computer Principles. Chapter 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 …
Time-sharing :
• All processes systematically put to working state (quasi-parallelism)• Short processes quickly finished• Medium and long processes not indefinitely waiting
1 32 4 108765 9 time
ready
Task ATask BTask C
ready
ready
ready
ready
ready
clock interrupt
D. Bertrand 13First Year University Studies in Science. ULB . Computer Principles. Chapter 12
ComparisonMulti-programmation
Time-sharingSimultaneous managementof several processes
Multi-management systems
optimisation ofcontrol unit usage
Response timeoptimisation (users)
Management ofseveral processes
Management ofseveral processes
quasi-parallelism
better use ofactive resources
Main aim Method Consequence
Multi-programmation
Time-sharing
Some operating systems based on a compromise
D. Bertrand 14First Year University Studies in Science. ULB . Computer Principles. Chapter 12
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 . tn : 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
D. Bertrand 15First Year University Studies in Science. ULB . Computer Principles. Chapter 12
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, …