Re: Critical section ?
From: Paul F. Johnson (paul_at_all-the-johnsons.co.uk)
Date: 12/21/04
- Next message: Rich: "Re: pesky Pointers !!"
- Previous message: rossum: "Re: using namespace std; discussion"
- In reply to: James: "Critical section ?"
- Next in thread: James: "Re: Critical section ?"
- Reply: James: "Re: Critical section ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 20 Dec 2004 23:50:31 GMT
Hi
James wrote:
> How can IncrementIndex be written so that it is thread safe and won't
> deadlock?
A deadlock is caused by thread A waiting for thread B to do something
and at the same time, thread B waiting for thread A to do something -
they both sit there until the user says blow this for a game and crashes
out.
A couple of ways to get around it - though neither are that good. The
first is to send one thread to sleep on return, so if A should return
first and B arrives first, send B to sleep and have something in A to
wake B up on A's termination. There is another way, but I've had too
much of the Christmas spirit to remember!
Threads can be very powerful, but very tricky.
TTFN
Paul
-- http://www.all-the-johnsons.co.uk Joy!
- Next message: Rich: "Re: pesky Pointers !!"
- Previous message: rossum: "Re: using namespace std; discussion"
- In reply to: James: "Critical section ?"
- Next in thread: James: "Re: Critical section ?"
- Reply: James: "Re: Critical section ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|