I studying read_lock and write_lock.
It seems that I can use spin_lock instead of read-write lock.
so I am wondering is there any advantages to use read-write lock
When I use read_lock and write_lock, what is advantages than just using spin_lock?
short googling turned this paragraph up:
Sometimes, lock usage can be clearly divided into readers and writers. For example, consider a list that is both updated and searched. When the list is updated (written to), it is important that no other threads of execution concurrently write to or read from the list. Writing demands mutual exclusion. On the other hand, when the list is searched (read from), it is only important that nothing else write to the list. Multiple concurrent readers are safe so long as there are no writers. The task list's access patterns (discussed in Chapter 3, "Process Management") fit this description. Not surprisingly, the task list is protected by a reader-writer spin lock.
(source: link)
so basically, using read_lock/write_lock gives you more power then regular spinlocks to deny/allow different lock-users, depending on their needs, like in the above example.