[E-Lang] Deadlock versus Datalock

Karp, Alan alan_karp@hp.com
Thu, 17 May 2001 16:52:22 -0700


One of the things that attracts me to E is the fact that I can't deadlock.
Wow!  I never have to worry about doing something stupid with the
synchronization and getting code that hangs.  Imagine my disappointment when
I read about datalock in EiaW.

I don't see any real difference between

	   P1				    P2
	getLock(A)			getLock(B)
	getLock(B)			getLock(A)
	free(B)			free(A)
	free(A)			free(B)

and

	xP <- getX()		yP <- getY()
	def getY() { 		def getX() {
	  when (xP)->done(x)	  when (yP)->done(y)
	  {  y  }			  {  x  }
      }				}

The former locks up the involved threads, but the latter prevents any work
from getting done.  The good news is that the data lock code can continue to
send its requests to the promises, but they never resolve, so no actual work
gets done.  The bad news is that the data lock code can continue to send its
requests to the promises, so when I get frustrated and interrupt the
program, I have no idea where the error is.  At least when I deadlock, the
program counter tells me what source line I'm stuck at. 

Actually, there is an essential difference.  The deadlock code will work
properly almost every time while the datalock code will fail every time.
Are there also race conditions with datalock?
	  
_________________________
Alan Karp
Principal Scientist
Decision Technology Department
Hewlett-Packard Laboratories MS 1U-3
1501 Page Mill Road
Palo Alto, CA 94304
(650) 857-3967, fax (650) 857-6278
https://ecardfile.com/id/Alan_Karp
http://www.hpl.hp.com/personal/Alan_Karp/