Chapter 13 - Concurrency Flashcards

1
Q

what are the 4 different levels of concurrency

A

machine instruction level

statement level

unit level

program level

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

what is machine instruction level concurrency

A

executing two more machine instructions concurrently

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

what is statement level concurrency?

A

executing two or more high-level language statements simultaneously

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

what is unit level concurrency?

A

executing two or more subprogram units simultaneously

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

6 motivations for concurrency

A
  • speed up execution
  • increase program flexibility
  • resource management in OS
  • task management in OS
  • solving large-scale problems
  • simulates actual physical systems that consist of multiple concurrent subsystems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is a scalable concurrent algorithm?

A

an algorithm with which the speed of execution increases when more processors are available

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

what is a thread of control?

A

a sequence of program points reached as control flows through the program

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

what is physical concurrency?

A

multiple independent processors (multiple threads of control)

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

what is logical concurrency?

A

the appearance of physical concurrency is presented by time-sharing one processor

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

what is hidden concurrency and what are 3 kinds of it?

A
  • concurrency that is built into processor architectures
  • pipelining of instruction (run instruction A, while preparing instruction B, while fetching instruction C)
  • separate lines (buses) for instructions and data
  • prefetching of instruction and data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

3 differences between a task (aka a process) and a subprogram

A

Tasks are:

  • implicitly started
  • invoking unit need not wait for the task to finish to resume itself
  • upon completion of the task, control may or may not return to the invoker
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is a lightweight vs a heavyweight task?

A

lightweight tasks all run in a single address space and heavyweight tasks each run in their own address space

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

what is a program “guard”

A

a linguistic device that allows the guarded code to be executed only when a specified condition is true

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

what is a task descriptor?

A

-a data structure that stores all of the relevant information about the execution state of a task

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

what is cooperation synchronization

A

when two processes must perform their work in some mandated order

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

what competition synchronization

A

when two processes need to access some resource but must not do it at the same time

17
Q

what is the Ada “accept” statement (3 things)

A

-its represents the entry point for a task using “Rendevous” for synchronization

each accept statement has an associated process queue

-the “server” waits when the accept statement is reached until a process meets the “when” statement requirements and is in one of its process queues

18
Q

rendezvous actor task vs server task

A

server task - a task with accept clauses

actor task - a task without accept clauses

19
Q

what is the Rendevous “pragma” keyword?

A

-assigns priority to tasks in the specification

20
Q

what is the Java “synchronized” keyword

A

when applied to methods within an object it disallows those methods from being run concurrently on different threads

when to applied to set of statements then those statements cannot be run concurrently by different threads

21
Q

4 java thread class methods

A

start- call the run method implemented in whatever runnable object

yield- a hint to the scheduler that the current thread is willing to yield its current use of the processor if needed. Moves thread to ready state

sleep- moves the thread into the blocked state

join- forces a method to delay its execution until the run method of another thread has completed its execution

22
Q

What is the equivalent of P and V for Java semaphores?

A
s = new Semaphore(0) --> constructor with initial value of zero
f = new Semaphore(MAX) 

s.acquire() //same as P
[blah, blah, blah]
f.release() //same as V

23
Q

2 ways to define a Java class with run() for threads

A
  • create a class that extends the Thread class and override run (only if the class has no parents)
  • create a that implements Runnable interface and define the functionality of run()
24
Q

what is the Java “notifyAll” method?

A

-it tells all other threads that some event that a thread may have been waiting for has possibly occurred

25
Q

what are atomic Integer, Boolean, and Long types?

A

-they are just like Integer, Boolean, and Long classes but their operations are non-interruptible