3.2.2: "lock requires two atomic ops"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



enjoying the updated edition!

"The lock operation is more expensive than CAS because it
 requires two atomic operations on the lock data structure, one
 for acquisition and the other for release."

this might be worth expanding upon. it's not immediately obvious
to me why the unlock would need to be atomic. the rough 2x
certainly jives with this explanation, and i intend to go look
at some source, but i'd think it would be more:

  atomic update
  fence
  non-atomic update

you've presumably got threads attempting to lock with a CAS
looking for a sentinel representing unlocked, right? so if i
update back to that sentinel in multiple steps, they're going to
miss in media res, no?

feel no obligation to respond, of course.

--nick

-- 
nick black -=- https://www.nick-black.com
to make an apple pie from scratch,
you need first invent a universe.

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux