Fundamentals Flashcards

1
Q

Define what is meant by the term ATOMIC ACTION (in the context of the concurrent execution of a program)

A
  • A programming instruction which changes the stage of a system indivisibly (i.e it can’t be interrupted by an instruction from another process)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define what is meant by the term FINITE PROGRESS ASSUMPTION (in the context of the concurrent execution of a program)

A
  • Assume that we can’t tell how fast the sequential components execute
  • If more than one process/thread can proceed then we must consider all the possibilities.
  • Non-determinism about which actual history of atomic actions will be executed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define what is meant by the term INTERLEAVINGS (in the context of the concurrent execution of a program)

A
  • An interleaving of a concurrent program is a list of the atomic actions of its sequential programs.
  • Within it, each sequential program is listed in the correct order, but the actions of different sequential components can be intermixed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define what is meant by the term HISTORIES (in the context of the concurrent execution of a program)

A
  • A history of a concurrent program is a possible interleaving of its atomic actions. Different possible actions when the program is run due to different interleavings.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In Java, a thread can be in one of FOUR STATES. Specify and describe the NEW state.

A

Thread can be in one of four states;

NEW - occurs when a thread is created but not yet running

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

Describe two approaches to creating threads in Java, illustrating your answer with example Java programs. When would you use each approach?

A

Method 1 - create a new subclass of the THREAD class and OVERRIDE the run() method

class SimpleThread extends Thread {
      public void run() {
           for (int count = 0; count  + Thread.currenthread().getName());
                }
       }//run
}//SimpleThread

Consider a main program that instantiates a runnable object (i.e notAThread) and passes it as a parameter to the constructor of Thread. The thread object (i.e parallel) can now be started.

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

Using examples to illustrate your answer, briefly explain what is meant by a concurrent system.

A

A concurrent system is one where several components are working at any time, and where useful work is going on in more than one place.

For example, if we consider an example in the form of a program called “Porter” - a concurrent system could utilise two of said porters working simultaneously, working to the benefit of the “processing” speed, but creating the possibility that they may interfere with one another.

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

Explain the use of threads in a concurrent system.

A

A thread essentially looks much like a process, and we can consider it as such.

A program can consist of multiple threads (running in a JVM - Java Virtual Machine)

  • Essentially, threads allow multiple tasks to be executed
    • they allow a single program multiple threads/paths of control.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Benefit of using threads - PROGRAM STRUCTURE

A

Sometimes, complex programs can be more clearly modeled using multiple threads, plus this makes them easier to understand and debug.

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

Benefit of using threads - SYSTEM RESOURCES

A

Whereas multiple processes typically means more resources are needed, multiple threads use only a fraction of the resources used by multiple processes.

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

Benefit of using threads - INTERACTIVE RESPONSIVENESS

A

Separate computation and I/O threads. I/O threads (in interactive situations), return quickly, giving better response times.

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

Benefit of using threads - PARALLEL EXECUTION

A

Threads provide a mechanism to achieve real parallelism. Different threads can run on different machines, and this can happen transparently in the case of multiple processors (user does nothing special).

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

In Java, a thread can be in one of FOUR STATES. Specify and describe the RUNNABLE state.

A

RUNNABLE - occurs when you invoke “start” on a thread

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

In Java, a thread can be in one of FOUR STATES. Specify and describe the BLOCKED state.

A

BLOCKED - occurs when someone calls “sleep()”, “suspend()” or the “wait()” method. Also when the thread calls an operation that is blocking on input/output.

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

In Java, a thread can be in one of FOUR STATES. Specify and describe the TERMINATED state.

A

TERMINATED - a thread terminates if

  • it dies a natural death because the “run” method exits
  • someone invokes its “stop” method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does a normal/sequential program consists of?

A

One ‘thread of control’, i.e statements are executed sequentially one after the other in a particular order

17
Q

What does a concurrent program consist of?

A

A set of sequential programs executing in parallel.

Sequential programs (such as the example about “Porters”) can be joined together as a concurrent program.

Potential parallelism; executions may but do not have to overlap; processes can share resources (e.g one processor)

18
Q

Give a brief description of a parallel program

A

Executions of programs occur at the same time - i.e overlap in time and potentially execute on separate processors

19
Q

Define a “process”

A

A program in execution, unit of work in an OS. A process is more than a thread in that it is a system level entity, whereas threads may be created at user level.

(e.g in the “Porter” example it would be, one of these Porter’s working)

20
Q

Why is multi-threading better (in theory) than multiprogramming

A

Processes have much higher overhead. Primitive mechanisms to coordinate.

By comparison, threads have much lower overhead. And a full complement of coordination mechanisms.

So, conceptually, threads are “cleaner”; hence they have been popular in OS theory