Concurrency Flashcards
What is interference?
Interference may occur when multiple threads try to modify shared
variables at approximately the same time (thus they need to share the same data
memory to do this)
What is an OS process
The student should probably draw a diagram how a computer has a number of OS
processes, the JVM runs in one of these processes, and this JVM can then support a
number of individual threads [1 mark]. The OS process is allocated independent
resources such as it own memory space for machine code, stack and data, thus
each process runs a different executable [1 mark]
What is synchronization?
This can be eliminated by synchronizing critical
sections of the code that modify the shared variables [1 mark] – this only permits
one thread access to the shared variables at a time within a critical section [1
mark]. The synchronization mechanism uses locking where only one thread at a
time can have the lock
Intrinsic Lock
The thread will get the lock at the start of the
critical section of code and give it back at the end, thus only allowing a single
thread to run in the critical section [1 mark].
What is the concurrency abstraction?
Based on having a number of processes, the abstraction models the overall system by interleaving the execution of atomic atoms of processes.
What is a abstract process?
Totally ordered sequence of atomic atoms.
What is a sequential program in the concurrency abstraction?
Consists of single process. assuming a fixed input, program is deterministic
What is a concurrent program in regards to the concurrency abstraction?
Consists of two or more processes carrying out atomic actions
What is an atomic action?
No divisible in terms of processing
What is interleaving?
describe a MODEL in which atomic actions from different processes are carried out.
Do atomic actions get carried out simultaneously?
No, in the concurrency abstraction they are interleaved.
Is a++ an atomic action?
No, consists of a LW a SW and a addi
What is a context switch?
When the OS moves from processing one process to the a different process
What is an OS process?
Used to run separate tasks which do not interfere with each other, each process has its own virtual memory address space for executable machine code, data, and stack
How are threads and OS processes different?
Threads share the same address space, thus share the same code