src/directory.cc
/*
 * we should call ToUnshared before call WLock
 */
we should call ToUnshared before call WLock
we should call ToUnshared before call WLock
int Directory::WLock(ptr_t ptr) {
  ptr_t block = TOBLOCK(ptr);
  DirEntry* entry = GetEntry(block);
  if (!entry) {
    entry = new DirEntry();
    entry->state = DIR_UNSHARED;  
    entry->locks[ptr] = EXCLUSIVE_LOCK_TAG;
    entry->addr = block;
    dir[block] = entry;
    epicAssert(IsBlockWLocked(entry) && IsBlockLocked(entry));
    return 0;
  } else {
    return WLock(entry, ptr);
  }
}
int Directory :: WLock ( ptr_t ptr ) { ptr_t block = TOBLOCK ( ptr ) ; DirEntry * entry = GetEntry ( block ) ; if ( ! entry ) { entry = new DirEntry ( ) ; entry -> state = DIR_UNSHARED ; entry -> locks [ ptr ] = EXCLUSIVE_LOCK_TAG ; entry -> addr = block ; dir [ block ] = entry ; epicAssert ( IsBlockWLocked ( entry ) && IsBlockLocked ( entry ) ) ; return 0 ; } else { return WLock ( entry , ptr ) ; } }
we should call ToUnshared before call WLock
we should call ToUnshared before call WLock
//epicAssert((ptr_t)ptr == TOBLOCK(ptr)); //actually this state only happens when locked