Interprocess Communication Flashcards
What’s the point of interprocess communication?
Processes often need to talk to other processes
What are the three key things interprocess communication needs to think about?
1) how processes can communicate with other processes
2) making sure processes don’t get in each other’s ways
3) proper sequencing and making sure dependencies are respected
Define race condition
Where two or more processes are reading or writing some shared data and the final result depends on who runs when
What does mutual exclusion allow:
that if one process is using a share dvariable or file, another process will not be able to use this fle.
Define critical section
the part of the program where the shared memory is accessed
What are the four conditions to create ensure that processes cooperate correctly?
1) No two processes may be inside their critical section
2) No assumptions can be made about speed or number of CPUs
3) No processes running outside critical section may block other processes
4) No process should have to wait forever to enter its critical section
What is busy waiting?
a technique in which a process repeatedly checks to see if a condition is true
what happens when you disable all interrupts?
you have a process disable interrupts when it enters its critical section. this means no clock interrupts can occur.
once a process has disabled all interrupts what can it do confidently?
access and update shared memory
give two reasons why is disabling interrupts unattractive?
1) if they never turned interrupts back on again, then the CPU would never get a look in
2) if the system has multiple processors, the other processors will not know that the process on another CPU has disabled interrupts. They will keep going as normal.
what is the spooler example?
when process wants to print a file, it tells the spooler directory
printer daemon checks if there are files to print
spooler has in and out variables
consider a spooler with an empty slot (7) and two files that want to print
item a reads a variable for next space to be 7
process switch immediately happens
item b reads same variable and also sets to 7. it continues and puts an item in 7 and sets next to 8
process switch
item a returns. it then puts a file in 7 and sets next space to 8
== item b has been overwritten
what are lock variables?
a software solution
process setting a lock variable to 1.
process enters the critical section
why are lock variables janky?
same idea as spooler directory
if one process reads lock as 0 and gets ready to make it 1, then process switches to something else and then THAT process also sets something to 1, then you’ll find yourself in the critical section for two process. NOPE.
define busy waiting
continuously testing a variable until some value appears
why should busy waiting be avoided?
wastes CPU time