@Jose
Does the use of semaphores has to be organized in the structure like the example they have on the RKM Libs ?
No.
or can the semaphore be anywhere in a structure (or even somewhere else ? Maybe there's some AmigaOS internal code that relies on a certain organization (the RKM doesn't mention it though, but I want to be sure).
Yes.
Last but not least, to protect more efficiently, in terms of multitasking, a list's elements from getting currupt because of multiple writes of different tasks, wouldn't it make more sense to have each of the list's elements have a Semaphore and then ObtainSemaphore() the two nodes between wich you want to insert a new one, or just a certain node's Semaphore if you just want to change some fields in the structure that contains it (rather than blocking the whole list everytime you want to do something to one of it's elements). This way other tasks accesing nodes that aren't being changed could continue to access them.
No. It would be horribly wasteful, and leave room for massive deadlocks (multiple semaphores must always be obtained in the same order, or a master semaphore lock must be used to arbitrate the sub-locking. Read the exec.doc ObtainSemaphoreList stuff, it's described there).
Also, the actual removal/insertation is very very fast, so the actual lock is only kept for a very short period. Since this is the case it doesn't really help at all to add any more complexcity layers from additional semaphores. In fact, it could be argued that Forbid/Permit protection would be even faster (if only insert/remove is used). If some very slow and complex operations are made while keeping the list "locked" then semaphore does pay off.
Since list iteration again involves locking the whole list (all the nodes, and they usually must not change inbetween), it doesn't really pay off to have any lower level granularity semaphores.
Also, doubly linked list Insert/Remove involves changing ptrs in 2 to 3 elements, in fact. For reference, see
dlist for doubly linked list implementation.
I hope I made some sense here.