chapter 5 Flashcards
General info about processes
- each process is indep, even tho multiple processes run on the same CPU
- they often share resources like code and data
- threads within a process operate in the same @ space
Virtual mem
- MMU is used to map a single physical memory area into multiple @ spaces, maps virtual @s used by processes to the actual physical @ in mem.
- abstraction that allows each process to believe it has its own continuous block of mem, however RAM is shared between all processes.
Race conditions
happen when multiple processes try to access and manipulate shared data at the same time.
shared mem
is a common method for IPC, where multiple processes can access the same mem to exchange info
threads
- access shared variables, thus synchro is needed
synchro
- manage how processes work together and how they manage shared resources
synchro strategy: lock variables
lock is global lock variable. critical section must acquire it and release it afterwards (similar to binary semaphore)
Lamport bakery algo
before a process is allowed to enter the critical section, it is assigned a wait number, this number indicates the position of the process in the queue to enter the critical section. The lowest wait number is the first to enter the critical section.
- problem if 2 processes have the same wait number, to mitigate this problem, having priorities could help
Busy waiting
- is when a process continuously checks if the lock is available, while it is blocked from proceeding. It holds teh CPU, restricting other processes from executing even if they are ready
synchro strategy: cli and sti
- cli is clear interrupt flag: disables interrupts ensiring that the current process isnt interrupted while it is in the critical section.
- sti is set interrupt flag: re-enables interrupts after the process finished executing he critical section.
Active waiting
- processes voluntarily yield control of the CPU while they wait for an event to occur. The PCB of the waiting process is placed in a queue and remains there until the event it is waiting for is ready. The waiting phase is called blocking phase
synchro strategy: semaphore
- it is a non-negative int thats manipulated by P (wait) and V (signal).
- implemets passive waiting
- P is decrement/wait: semaphore is decremented, signaling that the resource isnt available, being used
- V is increment/signal: semaphore is incremented, signaling that the resource is available again to be used
Unilateral synchro
producer and consumer, consumer waits for resources produced by the producer
Multilateral synchro
mutual exclusion