Locks Flashcards

1
Q

Race condition

A

when who processes are trying to change the shared resource .

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

what is a critical section

A

The part of process which access a shared resource is known as a critical section.

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

can you use single flag to overcome race condition.

A

No you cannot.

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

Solutions to race condition

A
  • run only one process in one CPU cycle
    -use mutex locks
    -semaphores
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Peterson’s solution

A

here we have variables such as other, interested and turn.
this solution only works for two processes.
if one of the process is in the critical section then the other cannot enter the critical section.

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

Contention

A

this is seen in case of mutex or locks that is here only one process or thread is allowed to access the CS in a given time, while others are waiting for that process to leave the CS, but if the process in CS get’s killed then other processes will go into infinite wait this is known as contention.

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

conditional variable

A

here we have wait and notify.
here if one process is in CS then the other doesn’t go in a wait state that is it does not CPU cycles.
when P1 is done using the CS then it notifies other processes that it is done so which ever process needs it, it then can access it.

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

Semaphores

A

we use this when we have multiple instances of a resource in CS, so multiple threads can access it.

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