CoSc 450: Programming Paradigms 01 What is Concurrent Programming?
M. Ben-Ari Principles of Concurrent and Distributed Programming Second Edition Addison-Wesley, 2006 c ≠ Mordechai Ben-Ari 2006
Computer Time ª - 0 100 200 300 400 500 time (nanoseconds) ! M. Ben-Ari. Principles of Concurrent and Distributed Programming, Second edition c ≠ M. Ben-Ari 2006 Slide 1.1
Human Time ª - 0 100 200 300 400 500 time (seconds) ! M. Ben-Ari. Principles of Concurrent and Distributed Programming, Second edition c ≠ M. Ben-Ari 2006 Slide 1.2
Figure 8.4 Primitive, one-job-at-a-time system Loader Job 1 Loader Job 2 Loader
Multiprogramming • An operating system that can switch back and forth between processes to keep the CPU busy is called a multiprogramming system • It maintains a queue of process control blocks (PCBs)
Asynchronous interrupts • Time outs • I/O completions
CoSc 450: Programming Paradigms 01 A multiprocessing system I/O request I/O request Time out Time out Time out Time out Time out ... J1 J2 J3 J1 J3 J2 J3
CoSc 450: Programming Paradigms 01 Observation It is impossible for the programmer to predict the statements in the program where the process will be interrupted by the operating system.
CoSc 450: Programming Paradigms 01 Process A process is a program during execution. The state of the process is specified by: • the program listing • the values of all the variables • the next instruction to execute program counter (PC)
Figure 8.18 Q Process ID Process ID Process ID CPU time CPU time CPU time PC PC PC SP SP SP
Figure 8.19 Waiting for I/O I/O complete I/O request Select to run Start Ready Running Finish Create Terminate Time out process process
Multiprocessing • A computer system with more than one physical CPU • Also maintains a queue of PCBs, but more than one process can be running at the same time
Figure 8.20 Input CPU CPU Main Output device 1 2 memory device Bus
CoSc 450: Programming Paradigms 01 The Concurrency Theorem Multiprogramming and multiprocessing are logically equivalent.
Recommend
More recommend