Previous | Next --- Slide 13 of 39
Back to Lecture Thumbnails
amolakn

Is the limit on performance caused because of the cost of modifying the lock in memory? Or is it simply because locking and forcing other threads to wait causes slowdown in itself?

Holladay

@amolakn I believe it is because we are forcing other threads to wait and therefore have forced an incredibly serial implementation. That would seem to be the larger issue.

ferozenaina

I think it would be both.

If we are trying to write a single element to a large array, capturing and releasing the lock (modifying the lock in memory) would be expensive. The other threads are forced to wait for because the locking would take >= time to write the element itself.

If this lock needs to be acquired by many other threads, we are essentially serializing the code.