Chow.Net
Chow.Net

Reputation: 593

is synclock in multithreading avoids deadlock

I have a multithreading program where I need to avoid deadlock. Is there any method to avoid deadlocks in multithreading?.

Thanks in Advance.

Upvotes: 1

Views: 921

Answers (1)

bazza
bazza

Reputation: 8414

Avoiding deadlock is a matter of proper design. Hacking together a multi threaded (or multi process) app is asking for trouble. Worse, testing is not adequate proof of a lack of deadlock.

You can adopt a programming paradigm suited to this sort of thing. Communicating Sequential Processes (CSP) was invented specifically to avoid deadlock, races, etc. A good pages to read is the JCSP page on Wikipedia. The idea makes it curiously hard to get deadlock, etc. and also you can mathematically prove (if you're feeling brave) that your design is free of such problems.

Unfortunately Microsoft have made it difficult to implement a CSP program in Windows either natively or in .NET. What's needed is a select() that works on pipes, which just doesn't exist in MS land. I hate to think what hurdles the JCSP team had to jump through to get their equivalent (Alternative in their parlance) working.

Upvotes: 2

Related Questions