60 likes | 249 Views
Concurrent and Distributed Systems. Introduction to CET306 Harry R. Erwin, PhD University of Sunderland. Texts.
E N D
Concurrent and Distributed Systems Introduction to CET306 Harry R. Erwin, PhD University of Sunderland
Texts • Clay Breshears (2009) The Art of Concurrency: A Thread Monkey's Guide to Writing Parallel Applications, O'Reilly Media, Pages: 304. This is available on www.amazon.co.uk as a paperback and more cheaply as a Kindle edition. You don't need a Kindle to read a Kindle edition. • Mordechai Ben-Ari (2006) Principles of Concurrent and Distributed Programming, Addison-Wesley. Also available on www.amazon.co.uk This is available as a paperback only. Covers the theory in depthand will be used as a supplementary text.
Basic Definitions • Concurrent Program—a set of sequential programs that can be executed in parallel (Ben-Ari). This should be thought of as abstract parallelism. • A Process is one of the sequential programs. • A Thread is a programming construct corresponding to a Process. • Distributed Program—a concurrent program that runs on separate computers and uses separate memory for each process. • Parallel Program—a concurrent program that runs on separate processors, but shares memory or data among processes.
More Definitions • Multitasking—when the execution of programs overlap on a single computer or CPU. This is a central function of the kernel of a modern operating system. • Multithreading—when a program contains multiple threads or processes on a single computer or CPU. • Task—another term for a schedulable entity or process. Tasks are commonly used in real-time systems to represent individual units of work. • Multitasking or multithreading systems often interleave instructions on a CPU. This makes analysis of their correctness quite difficult.
Example of Interleaving • There are six ways these processes can inter-leave: • p1; p2; q1; q2; • p1; q1; p2; q2; • p1; q1; q2; p2; • q1; q2; p1; p2; • q1; p1; q2; p2; • q1; p1; p2; q2; • Your concurrent pro-gram MUST run cor-rectly in all six cases. • Consider a concurrent program with two processes: Process 1: {p1; p2;} Process 2: {q1; q2;} • Where pn; and qn; are atomic operations.
Why is Concurrent Programming Hard? • Concurrent and distributed programs cannot be ‘hacked together’. Formal methods must be used to design them. • You must synchronise the execution of processes, and their communication. This has to be thought through carefully. • Illustration: In 1972-1979, TRW successfully built a high performance multi-tasking system for an important defence application. The application programmers on the project, including many of the world’s best at the time, were not trusted to implement concurrency correctly. The concurrency abstractions were allocated to the real-time operating system. We developed a ‘process design’ around those abstractions and an automated operating system test program to verify the correct implementation of the concurrency abstractions.