anchor.diff:  %% 3) TabLocks is the problem :-) They should not starve and not deadlock
   %%    handle tablocks in queue as they had locks on unlocked records.
   
  -can_lock(Tid, read, {Tab, Key}, AlreadyQ) when Key /= ?ALL ->
  -    %% The key is bound, no need for the other BIF
  -    Oid = {Tab, Key},
  -    ObjLocks = filter_write(?ets_lookup(mnesia_held_locks, Oid)),
  -    TabLocks = filter_write(?ets_lookup(mnesia_held_locks, {Tab, ?ALL})),
  -    check_lock(Tid, Oid, ObjLocks, TabLocks, yes, AlreadyQ, read);
  +can_lock(Tid, read, Oid = {Tab, Key}, AlreadyQ) when Key /= ?ALL ->
  +    ObjLocks = ?ets_lookup(mnesia_held_locks, Oid),
  +    TabLocks = ?ets_lookup(mnesia_held_locks, {Tab, ?ALL}),
  +    {check_lock(Tid, Oid,
  +		filter_write(ObjLocks),
  +		filter_write(TabLocks),
  +		yes, AlreadyQ, read),
  +     ObjLocks};
   
   can_lock(Tid, read, Oid, AlreadyQ) -> % Whole tab
       Tab = element(1, Oid),
       ObjLocks = ?ets_match_object(mnesia_held_locks, {{Tab, '_'}, write, '_'}),
  -    check_lock(Tid, Oid, ObjLocks, [], yes, AlreadyQ, read);
  -
  -can_lock(Tid, write, {Tab, Key}, AlreadyQ) when Key /= ?ALL ->
  -    Oid = {Tab, Key},
  +    {check_lock(Tid, Oid, ObjLocks, [], yes, AlreadyQ, read), undefined};
  +
  +can_lock(Tid, write, Oid = {Tab, Key}, AlreadyQ) when Key /= ?ALL ->
       ObjLocks = ?ets_lookup(mnesia_held_locks, Oid),
       TabLocks = ?ets_lookup(mnesia_held_locks, {Tab, ?ALL}),
  -    check_lock(Tid, Oid, ObjLocks, TabLocks, yes, AlreadyQ, write);
  +    {check_lock(Tid, Oid, ObjLocks, TabLocks, yes, AlreadyQ, write), ObjLocks};
   
   can_lock(Tid, write, Oid, AlreadyQ) -> % Whole tab
       Tab = element(1, Oid),
       ObjLocks = ?ets_match_object(mnesia_held_locks, ?match_oid_held_locks({Tab, '_'})),
  -    check_lock(Tid, Oid, ObjLocks, [], yes, AlreadyQ, write).
  +    {check_lock(Tid, Oid, ObjLocks, [], yes, AlreadyQ, write), undefined}.
   
   filter_write([{_, read, _}]) -> [];
   filter_write(Res) -> Res.
  
positive.code: 		    {not_granted, C}
  	    end
      end;
  grant_lock(Tid, {ix_read,IxKey,Pos}, Lock, Oid = {Tab, _}) ->
      try
  	Res = ix_read_res(Tab, IxKey,Pos),
  	set_lock(Tid, Oid, Lock),
  	{granted, Res, [?ALL]}
      catch _:_ ->
  	    {not_granted, {no_exists, Tab, {index, [Pos]}}}
      end;
  grant_lock(Tid, read, Lock, Oid) ->
      set_lock(Tid, Oid, Lock),
      {granted, ok};
  grant_lock(Tid, write, Lock, Oid) ->
      set_lock(Tid, Oid, Lock),
      granted.
  
  %% 1) Impose an ordering on all transactions favour old (low tid) transactions
  
negative.code: release_lock({Tid, Oid, {queued, _}}) ->
      ?ets_match_delete(mnesia_lock_queue, #queue{oid=Oid, tid = Tid, op = '_',
  						pid = '_', lucky = '_'});
  release_lock({Tid, Oid, Op}) ->
      case ?ets_lookup(mnesia_held_locks, Oid) of
  	[] -> ok;
  	[{Oid, Prev, Locks0}] ->
  	    Locks = remove_tid(Locks0, Tid, []),
  	    if Locks =:= [] ->
  		    ?ets_delete(mnesia_held_locks, Oid);
  	       Op =:= read ->
  