Week 3 Concurrent Programming Abstraction
Week 3 Concurrent Programming Abstraction
Concurrent Programming
Abstraction
Learning Outcomes
CT074-3-2
Concurrent Programming
Concurrent Programming
Levels of abstraction
Systems and libraries
OS and librariesoften called Application
Program Interfaces (API)define
computational resources that are available to
the programmer. You can open a file or send
a message by invoking the proper procedure
or function call, without knowing how the
resource is implemented.
CT074-3-2
Concurrent Programming
Levels of abstraction
Programming languages
A programming language enables you to
employ the computational power of a
computer, while abstracting away from the
details of specific architectures.
CT074-3-2
Concurrent Programming
Levels of abstraction
Instruction sets
Most computer manufacturers design and build
families of CPUs which execute the same
instruction set as seen by the assembly language
programmer or compiler writer. The members of a
family may be implemented in totally different
waysemulating some instructions in software or
using memory for registersbut a programmer
can write a compiler for that instruction set
without knowing the details of the implementation.
CT074-3-2
Concurrent Programming
Levels of abstraction
logic gates and implementation by
semiconductors no thanks!
X=y+z -> electrons in chips
CT074-3-2
Concurrent Programming
Software abstraction.
Encapsulation
Concurrency
CT074-3-2
Concurrent Programming
Encapsulation
Data hiding
Achieves abstraction by dividing a software module into a
public specification and a hidden implementation.
Specification describes the available operations on a data
structure or real-world model.
Detailed implementation of the structure or model is written
within a separate module that is not accessible from the
outside.
Changes in internal data representation and algorithm without
affecting the programming of the rest of the system.
Modern programming languages directly support
encapsulation.
CT074-3-2
Concurrent Programming
Encapsulation
CT074-3-2
Concurrent Programming
10
Private!
public class Employee {
private BigDecimal salary = new BigDecimal(50000.00);
public BigDecimal getSalary() {
return salary;
}
public static void main() {
Employee e = new Employee();
BigDecimal sal = e.getSalary();
}
CT074-3-2
Concurrent Programming
11
Concurrency
Abstraction designed to make it possible
to reason about the dynamic behavior of
programs.
There are no important concepts of
concurrency that cannot be explained at
the higher level of abstraction.
CT074-3-2
Concurrent Programming
12
Concurrent execution as
interleaving of atomic
statements
CT074-3-2
Concurrent Programming
13
Definition
A concurrent program consists of a finite set of
(sequential) processes. The processes are written using
a finite set of atomic statements. The execution of a
concurrent program proceeds by executing a sequence
of the atomic statements obtained by arbitrarily
interleaving the atomic statements from the processes. A
computation is an execution sequence that can occur as
a result of the interleaving. Computations are also called
scenarios.
CT074-3-2
Concurrent Programming
14
Definition
During a computation the control pointer
of a process indicates the next statement
that can be executed by that process.
Each process has its own control pointer.
Alternate terms for this concept are instruction
pointer and location counter.
CT074-3-2
Concurrent Programming
15
CT074-3-2
Concurrent Programming
16
2 processes, p and q
p
q
p2
CT074-3-2
p1, p2
q1, q2
p1
q1
q2 ??
Concurrent Programming
17
CT074-3-2
Concurrent Programming
18
CT074-3-2
Concurrent Programming
19
CT074-3-2
Concurrent Programming
20
CT074-3-2
Concurrent Programming
21
CT074-3-2
Concurrent Programming
22
Q&A
CT074-3-2
Concurrent Programming
23