Previous | Next --- Slide 8 of 65
Back to Lecture Thumbnails
unparalleled

Contrast between lock and lock free: Lock: one thread at a time, mutual exclusion Lock free: no provision to guarantee that two threads are running pop at the same time. Do not worry about mutual exclusion, go ahead and do your job. If no other thread has modified when I was doing the modification then update, else wait for the change to be updated.

Abandon

Mutex: Only one can operate at a time. lock free: many threads can operate together, but only one can succeed.

zckchange

Which one is better in a specific situation? Mutex or lock free?

googlebleh

@zckchange That's a very open-ended question. It depends a lot on what you mean by "better," and what the situation is. You'd have to consider what's important to you for that application. See Slide 35 of Lecture 17 for some possible reasons/scenarios.

fxffx

Using locks: guarantee that only one thread will modify the stack at one time; Lock-free: not guarantee that only one thread will modify the stack at one time, but if not, only one thread will succeed and others will start over.