Concurrency Flashcards

1
Q

independent processes

A

can’t be affected by others and vice versa

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

cooperating processes

A

can be affected and can affect other processes

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

reasons for communication

A
  • information sharing
  • computational speedup (e.g. breaking down a big task to multiple small tasks)
  • modularity (system is divided into modules that need to communicate)
  • convenience (multitasking by the user, e.g. listening to music while writing a document)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Ctrl+Z

A

suspends a process, doesn’t terminate

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

signal types

A

Hardware-induced (e.g., SIGILL)
Software-induced (e.g., SIGQUIT or SIGPIPE)

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

actions

A

term
ign
core
stop
cont

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

catching signals

A
  • Process registers signal handler
  • OS delivers signal and allows process to run handler
  • Current execution context needs to be saved/restored
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

kernel delivers the signal

A

→ Stops code currently executing (after saving contacts- states of registers- of the current program)
→ Saves context
→Executes signal handling code
→Restores original context

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

signal info pushed onto the stack

A

floating point state
ucontext: SP and IP
siginfo - info about the signal
sigreturn - SP; address to where to return after the signal handler finishes

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

upon sigreturn, the kernel

A
  • can simply take all the state on top of stack
  • and restore:RIP = …
    RSP = …
    RAX = …
    RBX = …
    etc.
  • vulnerability: not stored in the kernel so it can be modified by an user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

reasons for synchronisation

A
  • To account for dependencies
  • To avoid processes getting in each other’s way
  • Also applies to multithreaded execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

fork()

A
  • creates a separate, duplicate process
    • new PID
    • continues after
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

exec()

A
  • the program specified in the parameter will replace the entire process - including all threads
    • same PID
    • doesn’t continue after
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

race conditions

A

a situation in which several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place

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

spooler directory

A

a designated area where files are temporarily stored while they are being processed by a program or service, typically related to printing or job management

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

critical region

A

a code region with access to shared resources

17
Q

requirements to avoid race conditions

A
  1. No two processes may be simultaneously in their critical regions
  2. No assumptions may be made about speeds or number of CPUs
  3. No process running outside its critical region may block others
  4. No process should have to wait forever to enter its critical region
18
Q

a solution to the critical region problem must satisfy

A
  1. mutual exclusion: when one process is executing in its critical region, no other process is to be allowed to execute in its critical region
  2. progress: no process should have to wait forever to enter its critical region
  3. bounded waiting: there exists a bound on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before the request is granted
19
Q

Peterson’s solution

A

when a process wants to enter its critical region it sets its flag to true and it will set the turn to the other process, i.e. it gives the turn to the other process

20
Q

semaphore

A
  • a nonnegative int variable shared between processes
  • it can be accesses through two standard atomic operations: wait() and signal()
21
Q

semaphore idea

A
  • Idea: introduce a special semaphore integer type with 2 operations:
    • down (wait):
      • if semaphore ≤ 0 then block the calling process
      • semaphore = semaphore - 1 otherwise
    • up (signal):
      • if there is a process blocking on semaphore, wake it up
      • semaphore = semaphore + 1 otherwise
    • OS guarantees all the operations are atomic by design
      • Disable interrupts on single processors
    • Spin locking on multiprocessors
22
Q

binary seamphores

A

mutex locks
only 0 or 1

23
Q

spinlock semaphore

A

busy waiting wastes CPU cycles that some other process might be able to use - the process “spins” while waiting for the lock

24
Q

Readers/Writers

A
  • Idea: Build a queue of readers and writers
  • Let several readers in at the same time
  • Allow 1 writer when no readers are active
  • How long may the writer have to wait?
25
Q

monitors

A
  • more structured approach towards process synchronisation:
    • serialise the procedure calls on a given module
    • use condition variables to wait / signal processes
    • a monitor type presents a set of programmer-defined operations that provide mutual exclusion the monitor
  • requires dedicated language support
26
Q

shared memory systems

A

the shared memory region is typically in the address space of the process creating the shared-memory segment
the other process attaches the region to its address space
the processes can access each others memory (since the area is in the address spaces)

27
Q

unbounded buffer

A

no size limit ⇒ the consumer might have to wait for new items, but the producer can always produce new items

28
Q

bounded buffer

A

size limit ⇒ the producer must wait if the buffer is full, the consumer has to wait if its empty

29
Q

message passing

A
  • allows processes to communicate and synchronise their actions without sharing the same address space
  • particularly useful in a distributed environment, where the communicating processes may reside on different computers connected by a network
  • Most common choice in multi-server OS designs
30
Q

message passing messages

A

send(destination, &message);
receive(source, &message);
receive(ANY, &message);

31
Q

priority inversion

A
32
Q

Read-Copy-Update

A
  • An instance of relativistic programming
  • Do not try to avoid conflicts between readers and writers; tolerate them and ensure a correct result regardless of the order of events
  • Allow writer to update data structure even if other processes are still using it.
    • Parallel copies of a data structure.
    • Ensure that each reader either reads the old or the new version, but not some weird combination of the 2.
    • single-pointer readers/writers scheme
33
Q

marshalling

A

packing the parameters into a form that can be transmitted over a network

34
Q

RPC

A

protocol that one program can use to request a service from a program located in another computer on a network without having to understand the network’s details

35
Q

The bounded buffer problem

A
  • also producer-consumer problem
  • the producer must not insert data when the buffer is full
  • the consumer must not remove data when the buffer is empty
  • the producer and consumer should not insert and remove data simultaneously
36
Q

The dining philosophers problem

A

resource allocation problem