Units 3 & 4 Flashcards

(41 cards)

1
Q

Shared resources

A

processes that are working together often need to access the same data or hardware resource

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

Producer-consumer model

A

2 or more processes working with a shared resource

producer - writes data to the shared resource

consumer - reads data from the shared resource

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

Condition synchronisation

A

mechanism to ensure that a process is blocked if some condition is not met

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

Mutual exclusion

A

control access to shared data

only one process at a time had exclusive access to a shared resource

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

What are race conditions?

A

when the final outcome of a process is dependent on the timing or sequence of other processes

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

Atomic action

A

either happens completely or it does not happen at all

fine-grained or course-grained

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

Critical region

A

a section of code in which a shared resource is being accessed

must be executed under mutual exclusion

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

Entry protocol

A

code that must be executed before entering a critical region

prevents a process entering the critical region if another process is already in a critical region that accesses the same data resource

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

Exit protocol

A

code that a process must execute immediately on completion of its critical region

signals the resource is now available to other processes

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

Semaphore

A

data structure for solving synchronisation problems

like a permit - only one process at a time can hold the permit + a process must get hold of the permit before it can enter the critical region

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

Binary semaphore

A

for mutual exclusive access to a single shared resource

several processes sharing a resource will share one semaphore

initial value of 1

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

Counting semaphore

A

to protect access to multiple instances of shared data

initial value set to the number of resource instances available

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

Blocking semaphore

A

to synchronise two processes

initialised to 0

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

Monitors

A

data structures to encapsulate the shared data

shared data is accessible only through special monitor operations which are atomic

facilitate mutual exclusion

support condition synchronisation

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

Monitor construct

A

well-defined interface

only operations defined in the interface can be used to access the monitor’s data

a monitor operation is equivalent to a critical region with entry + exit protocols

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

In what ways can semaphores be used?

A

ensuring mutual exclusion from critical code

controlling access to shared resources

synchronising cooperating processes

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

How can the incorrect use of semaphores lead to problems?

A

by forgetting to use semWait it is possible for a resource be become unprotected

by forgetting semSignal it is possible for a resource to become locked indefinitely

18
Q

Condition variables

A

special variables associated with the monitor that enable the monitor to handle condition synchronisation

have a queue - if a condition is not satisfied a process can be made to wait in a queue for that specific condition

19
Q

Thread safety

A

a class is said to be thread safe if it can be executed concurrently by several threads in a safe manner - without data getting into an inconsistent state

20
Q

Multiple readers, single writer policy

A

readers - threads that read the contents of a file

writers - threads that write to a file

need to keep track of how many threads are currently reading or writing - 2 variables:
      int activeReaders      (>= 0)
      int activieWriters        (1 or 0)

reader thread needs to check the value of activeWriters before it begins to read

a writer thread should check the values of both (one writer only)

21
Q

Writers-preferred policy

A

shared resource is given to a waiting writer (if there is one)

only if there is no writers waiting will it be given to readers

all waiting readers will be allowed access at the same time

22
Q

Readers-preferred policy

A

the shared resource is given to all waiting readers (if there are any) + is given to a writer only if no readers are waiting

23
Q

Alternating reader-writers policy

A

shared resource is given to a waiting writer when readers have finished + to readers when writers have finished

24
Q

Take a number policy

A

shared resource is given to threads in order of arrival

25
Do you think the writers-preferred policy is fair?
possible that the reader processes never get a chance to run because writer processes always get priority
26
What are the 4 conditions of deadlock?
1. mutual exclusion 2. hold while waiting 3. no pre-emption 4. cycle of processes
27
How can deadlock be prevented?
by arranging for one of the 4 conditions to not be true
28
Advantages of virtual machines
can be executed on various platforms facilitate the developments of applications written in multiple languages generated virtual code is smaller than the corresponding machine code
29
Disadvantages of virtual machines
slower execution speed of the program
30
Virtual machine (VM)
an abstract computing device that implements in software a hypothetical platform compile programs for virtual platform + implement the virtual machine on top of various concrete platforms
31
Interpreter
the implementation of a virtual machine consists of an interpreter a program that executes another program
32
Class loader
able to load a class file into the method area of an already running program classes are loaded into the JVM only when they are needed - helps to minimise memory usage
33
Bytecode verifier
devices receiving code should have some guarantee that it is safe to run that code verifier scans the bytecode before it is executed
34
Garbage collection
mechanism that reclaims the memory occupied by unused objects from the heap to keep memory usage as low as possible
35
3 Java Platform editions
1. Enterprise edition (Java EE) 2. Standard edition (Java SE) 3. Micro edition (Java ME) * each edition is a set of tools, libraries, API specifications, etc for a certain kind of system
36
Lock interface
locks have to be explicitly acquired and released by calling lock + unlock methods if developer for gets to call unlock the application might deadlock - this cannot happen with the build-in object lock because they are automatically released by the JVM
37
Condition interface
allow multiple explicit condition variables for each lock
38
Countdown latch
CountDownLatch class implements a thread execution barrier with a counter if counter positive, barrier down + threads arriving at latch have to wait if counter 0, barrier up + all waiting threads resume execution has two operations: wait + notify
39
Factory methods
a method that creates objects of a given type C typically are static methods and C is an interface used when: - the creation of a C object is complex - the exact implementation of C should be kept hidden
40
What is one of the central concerns for correctness of multithreaded applications?
changes made to shared variables by one thread must be visible to all other threads reading those variables
41
Through which method calls can a Java thread release control?
sleep yield wait join