Fundamentals Flashcards

1
Q

What are concurrent systems?

A

Several components working at any one time.

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

What is concurrent programming?

A

Writing programs which allow different parts of a system to execute concurrently and to co-operate.

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

What are the advantages of concurrent programming?

A

Processing can go faster

Sometimes easier to program than sequential systems

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

What are the disadvantages of concurrent programming?

A

Components can interfere with each other

Components need to communicate and cannot work independently

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

What is multitasking?

A

Two (single threaded) applications running on a PC

e.g. editor and file manager, can executed independently and also interact (drag a file over, etc)

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

What is multi-threading?

A

A thread is like a process, with a program consisting of multiple threads

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

What is the Hospital Porter scenario

A

Room for one patient, two different porters
Treatment room is too small, can cause collisions
Porters could find empty rooms
Synchronisation (multual and conditional) is needed to solve the problems

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

What is mutual synchronisation?

A

Only one thread/process can gain access at any one time

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

What is conditional synchronisation?

A

Threads can only execute when a condition is met

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

Why are threads used in concurrent systems?

A

Allow a single program multiple threads/paths of control
Lower overhead than processes, full complement of coordination mechanisms
Conceptually cleaner

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

Advantages of using threads in Concurrent Systems

A

Cheap - implemented at user level, no kernel resources
Efficient - no system calls or switching modes involved
Parallel execution - can make use of multi-CPUs
Higher Application Throughput - Puts I/O on different thread
Interactive Responsiveness - I/O responds faster
Better communication - threads share address space
Resources - Threads use a fraction of resource space
Distributed objects are inherently multi-threaded
Easy to write, understand, and debug
Shared standards - POSIX
Shares parent resources hence cheap to start

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

What is a disadvantage of using threads in Concurrent Systems?

A

Shares parent resources which is cheap to start but must worry about concurrent access. fork() takes a copy which is expensive to start but means no worrying over access later

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

What does a ‘normal’ program consist of?

A

Statements being executed in sequential order ie one thread of control

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

What does a ‘concurrent’ program consist of?

A

Set of sequential programs executing in ‘parallel’ with a process essentially being an executing program
Potentially parallel but resources can be shared and time-sliced (e.g. one processor)

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

What does a parallel program consist of?

A

Executions occur at the same time, usually using separate processors

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

What is a process?

A

Process is a program in execution
Kernel level entity
Single process can have multiple threads

17
Q

What is a Thread?

A

Single line or stream of control
Created at user level
Thread essentially looks like a process

18
Q

What are the 4 stages of threads?

A

New
Runnable
Blocked
Terminated

19
Q

When is a thread new?

A

Created, but not yet running

20
Q

When is a thread runnable?

A

When start is invoked

21
Q

When is a thread Blocked?

A
  1. When sleep is called
  2. When suspend is called
  3. When thread calls wait
  4. When threads calls an operation that is blocking on input/output
22
Q

When is a thread terminated?

A

If run method exits
OR
stop method is invoked

23
Q

What does the thread method yield do?

A

Yields control away from that thread to others to allow them to temporarily execute

24
Q

What does the thread method setDaemon(boolean) do?

A

Thread can be set as a Daemon, which means the JVM will exit even is Daemon Thread is still running

25
Q

What are the two methods of creating threads?

A

Extend ‘Thread’ and override the run method

Implement runnable, provide a run method

26
Q

Why is the extend ‘Thread’ method limited?

A

Because the class must be a subclass of Thread and cannot subclass another

27
Q

What is time-slicing?

A

Threads are run for short periods of time and suspended
Resumes when it becomes their turn again
Threads of same priority share turns

28
Q

How does a single process achieve concurrency?

A

Time-slicing

29
Q

Does Java specify if the scheduler performs time slicing?

30
Q

How would a user test for time slicing?

A

Define a thread class that will run forever
Create two of these threads and start them
If timesliced, 0 and 1 will intermix
If not timesliced, 0 will repeat forever

31
Q

What is meant by Atomic action?

A

Action that can’t be interrupted by an instruction from another process.
Once an atomic action reads a variable, if subsequently re-read, it can be assumed it’ll remain the same.

32
Q

What is Finite Progression Assumption?

A

If more than one process/thread can proceed, then we must consider all possibilities.
It is non-deterministic, however.
Assume if there is one to proceed then it will

33
Q

What are interleavings?

A

An interleaving of a concurrent program is a list of atomic actions of its sequential programs.
Within the interleaving, each sequential program is listed in correct order, but the actions of different sequential components can be intermixed.
(t1, t2, u1, u2)
(t1, u1, t2, u2) both interleavings of same statement

34
Q

What are Histories?

A

A history of a concurrent program is a possible interleaving of its atomic actions.