You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
-
If you do something like this, I'd probably measure performance with various list sizes, and if there's a crossover point where performance is better the bigger the list, just use coarse-grained locking with small lists and switch to granular locking with big lists.Craig Tullis– Craig Tullis2015-06-03 23:52:36 +00:00Commented Jun 3, 2015 at 23:52
-
Say you have a list like A-B-C-D. Core 0 tries to delete B and Core 1 tries to delete C. Core 0 locks B, core 1 locks C, core 0 locks A, core 1 blocks on locking B, core 0 blocks on locking C. deadlockGoswin von Brederlow– Goswin von Brederlow2015-06-03 23:57:45 +00:00Commented Jun 3, 2015 at 23:57
-
1@GoswinvonBrederlow there are ways to mitigate deadlocks. If a thread cannot lock every node it needs, it should immediately release the locks it already has and wait a random (but small) amount of time and repeat.user22815– user228152015-06-04 00:05:41 +00:00Commented Jun 4, 2015 at 0:05
-
1Another option is to have an object that manages the locks. A lock request comes in with all of the nodes (pointers, IDs, whatever) that a thread needs to lock. Each lock is processed atomically and could either fail or block if unable to proceed at the current time. There are options here.user22815– user228152015-06-04 00:06:52 +00:00Commented Jun 4, 2015 at 0:06
-
@GoswinvonBrederlow core0 should lock in order A-B-C and core 1 should lock B-C-D, aka always lock the node closest to the head first, if the group wraps (you want to insert before A) then you should lock A-B-D. This way there is no deadlock.ratchet freak– ratchet freak2015-06-04 07:52:51 +00:00Commented Jun 4, 2015 at 7:52
|
Show 7 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you