Lecture 4&5-Concurrent vs sequential programming Flashcards

1
Q

What is the Kernel vs User Mode?

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

What is a Heavyweight processes?

A

A process is an operating system abstraction to represent what is needed to run a program.

It consists of:

  • Sequential Program Execution Stream (includes state of CPU registers)
  • Protected resources: memory state, I/O state

No concurrency inside heavyweight processes!

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

What is PCB, address space and context switch?

A

The current state of the process is held in the PCB (Process Control Block)

To multiplex several processes we need to give CPU time using efficient scheduling policies.

  • preemptive: SRT, RR
  • non-preemptive: FCFS, SJF

Controlled access to non-CPU resources, e.g. memory, I/O.

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

What are Threads?

A

A thread is an independent sequence of execution within a program

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

What is the Concept of Thread?

A

A thread is similar to a process

  • Both have a single sequential flow of control with a start and end
  • At any time a thread has a single point of execution
  • A thread has its execution stack & program counter
  • Sometimes a thread is called a lightweight process

However, a thread differs from a process

  • A thread cannot exist on its own. It exists within a process
  • Usually created and/or controlled by a process
  • Threads can share a process’s resources, including memory and open files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Sequential Programming?

A

Traditional activity of constructing a program containing one process using a (sequential) computer language

The program is supposed to execute on a single processor architecture

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

What is Single Processor Architecture?

A

A CPU is linked to RAM and I/O devices by buses
Both program instructions and data are stored in RAM
The CPU repeatedly executes the cycle of

  • Fetching, decoding and executing the next instruction
  • Referenced by the current value of program counter (PC)

Can at most be executing one instruction at any time

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

What is Total Ordering?

A

What is meant by “P must precede Q”?
Q can only begin after P finishes
The execution sequence at the program level
P; Q; R;
implies the execution sequence at the system level
p, q1, q2, q3, r1, r2, r3
Single threaded computation, no overlap in the execution of the
statements — Total Ordering

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

What is System Level Execution?

A

Each statement may be compiled into several machine instructions.

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

Executing a Sequential Program?

A

The execution sequence is the sequence of values of PC

Deterministic: only one possible sequence of execution

A sequential program gives the system strict instructions on the order of executing the statements in the program.

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

What is the Nature of Sequential Programming?

A

Total ordering
Deterministic: same input same output
Sequential programming ⇔ Finding a strict sequence of steps to achieve the desired end
This mode does not apply for many practical problems

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

What is Parallel Computation and Partial Ordering?

A

The operations carried out by Bingxing’s 607279 soldiers were NOT in a total order.

They were carried out in parallel

Each individual soldier did his operations in sequence

The operations in the whole computation can be viewed as in a partial order

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

What is Concurrent Programming?

A

The activity of constructing a program containing multiple
processes/threads that execute in parallel
These processes may run on
A multi-processor system
A single processor system
Needs language support, e.g., Java Thread and Socket

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

Why Concurrent Programming?

A

Improve efficiency in program execution using multi-CPU hardware
(Chinese General Problem)
Improve CPU utilisation via multi-tasking on a uni-CPU system
(operating systems)
Some applications are inherently non-deterministic and concurrent,
e.g., embedded traffic lights controller
The order of program operations is determined by external events,
e.g., a sensor is triggered by a coming vehicle
Impossible to predict the order of these events, e.g., a car from the north comes first, and then one from the east, and so on

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

How to Represent Concurrent Program?

A

Use COBEGIN/COEND to bracket the processes

The program ends only if all processes in COBEGIN/COEND
terminate

The statements in COBEGIN/COEND may overlap in the
execution, but we cannot say they must do so

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

What is a Multi-Processor System?

A

A computer with multi-CPUs is called a Parallel Computer System

Parallel computation can be implemented on a parallel computer system

If each task is computed by its own CPU, the computation is called Maximum Parallel Computation

E.G., if a system has 607279 CPUs, each soldier’s task can be assigned to its own CPU

Maximum parallelism may not be always possible

17
Q

What is a Uni-Processor Multi-Tasking System?

A

A uni-CPU system can support multi-tasking/multi-thread
We can treat each soldier as a process or thread

Each process/thread has its own process counter

The program counter (PC) forks to produce many process/thread counters, which later join into the PC

In each CPU cycle, a process is non-deterministically chosen and its next command is loaded and executed

There may be many different possible paths

This CPU sharing technique is interleaving. The execution of processes in a concurrent program is interleaved

18
Q

Problems in Concurrent Programming?

A

The concurrent processes must interact with each other in order to share resources or exchange data

Synchronisation: when, how, and with what language
abstractions we can synchronise computation events to
eliminate unacceptable interleavings, and thus inacceptable outputs

Distribution: how we can distribute processes among a
number of processors, and how a process on one processor can interact with another process on a different processor.