|
-
May 20th, 2005, 05:16 PM
#1
deadlock avoidance
I'm working on a thread safe smart pointer class listed in the following links:
http://code.axter.com/sync_ptr.h
http://code.axter.com/sync_ctrl.h
One feature I'm trying to add to this class is the ability to detect an attempt to create a deadlock.
For those who don't know what a deadlock is, say you have global object A and object B and they're using above smart pointers. Then say you have two threads:
Thread1: obj_A->SomeFunction(obj_B->GetData());
Thread2: obj_B->SomeFunction(obj_A->GetData());
If the above two threads make these calls at the same time, you'll get a deadlock since each lock is waiting for the other lock to unlock.
So I'm looking for any good suggestions, since I'm stumped, and I’m trying to do some brainstorming.
I posted this question in one of the newsgroup, and so far the only really good suggestion I got was to create a priority list for all locks (sync_ptr).
That method could work, but that would require the developer to be proactive in creating priorities for each sync_ptr object created.
I’m looking for a method that would require less work on the developer’s part.
I’ll take any and all suggestions, so please feel free to throw them at me.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|