Welcome, Guest. Please login or register.

Author Topic: Semaphore rules/Efficiency using semaphores in list objects  (Read 2293 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show all replies
Re: Semaphore rules/Efficiency using semaphores in list objects
« on: December 24, 2005, 12:55:54 PM »
No, it wouldn't. The reason is that list operations (finding nodes, removing nodes, adding nodes) need the node structure to begin with; if parts of them are locked, then the list operations cannot continue. Therefore locking separate nodes still implies a master lock on the list itself, albeit a read-only one. The idea of semaphores, mutexes and spin locks is that you provide synchronised access to a data set: as long as a task is busy with data, all others must wait. You could attempt to read a locked data structure, but since the contents are by definition uncertain, you cannot do anything useful with it. Not even print the contents. The only solution is not to link the separate data structures into a list.

For a very good introduction to this fascinating topic, I recommend this site.
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.