Week 2 - Concurrency Flashcards

1
Q

Concurrency

A

Sequential system: Where parts of a computation are executed to completion, one after each other.

Concurrent System: Is where one or more computations are executing at the same time.

Concurrent system is almost the same as a parallel system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Concurrency issues

A

Multi-tasking operating systems, where many processes are running at once.

Individual applications like Web Servers, that could be processing many “requests” simultaneously.

Multicore processors where single application is running across more than one core.

Parallel computers and Distributed Systems in general.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Threads

A

Specific sequence of instructions defined by same program, or by section of it.

These instructions sequences can run in parallel or interleaved in an unpredictable way.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Processes

A

Processes have one or more threads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Processes and Threads

A

Every process has at least one control flow with a single address space.

A process may have multiple control flows within the same address space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Parallelism vs Multitasking

A

Threads may run on different cores making it truly parallel.

Multiple threads share the same “core” by multitasking.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Concurrent Programs

A

Use thread libraries.

For example occam, uses PAR for do in parallel, and SEQ to execute in sequence. (This is for code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

POSIX threads

A

POSIX stands for Portable Operating System Interface.

Low-level programming language, often used in the C language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Create POSIX parent thread

A

When creating it calls pthread_create library, passing it a pointer of a function with code for new thread.

A parent can create any of number of threads, just as a child can create their own children.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Concurrency in Java

A

Java creates threads using libraries it doesn’t contain explicit parallel constructs.

But supports concurrency through modifiers like synchronized, volatile on declarations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JAVA threads

A

Similar to POSIX, but uses OOP patterns.

run is defined as java.lang.Threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Concurrent programs

A

Number of possible orderings grow massively with program size.

As a result it is harder to design and debug programs.

non-deterministic meaning different orders of execution may lead to different outcomes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Interference

A

More serious case of non-determinism.

Programmer might have expected each thread increments variable c by 1.

Making c increase by 2.

Unpredictable behaviour, when concurrent threads adversely affect one another’s behaviour, is called interference.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Race Conditions

A

Race conditions is the name given to interference, they are the same thing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Avoiding Interference

A

To avoid this race condition type is to make sure that threads never have any variables in common.

What happens with processes, it having different address spaces, and no variables shared.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Critical Sections

A

General sections of code that must not overlap are called critical sections.

17
Q

Mutual Exclusion

A

Techniques to ensure that critical sections do not overlap during execution of a concurrent program.