src/worker.cc
// Workload for testion memory or MMIO regions.
// Return false on software error.
Workload for testion memory or MMIO regions.
Return false on software error.
Workload for testion memory or MMIO regions . Return false on software error .
bool MemoryRegionThread::Work() {
  struct page_entry source_pe;
  struct page_entry memregion_pe;
  bool result = true;
  int64 loops = 0;
  const uint64 error_constant = 0x00ba00000000ba00LL;
  int64 *addr = 0x0;
  int offset = 0;
  int64 data = 0;
  logprintf(9, "Log: Starting Memory Region thread %d\n", thread_num_);
  while (IsReadyToRun()) {
    phase_ = kPhaseNoPhase;
    result = result && sat_->GetValid(&source_pe);
    if (!result) {
      logprintf(0, "Process Error: memory region thread failed to pop "
                "pages from SAT, bailing\n");
      break;
    }
    result = result && pages_->PopRandom(&memregion_pe);
    if (!result) {
      logprintf(0, "Process Error: memory region thread failed to pop "
                "pages from queue, bailing\n");
      break;
    }
    if ((sat_->error_injection() || error_injection_) && loops == 1) {
      addr = reinterpret_cast<int64*>(source_pe.addr);
      offset = random() % (sat_->page_length() / wordsize_);
      data = addr[offset];
      addr[offset] = error_constant;
    }
    phase_ = kPhaseCopy;
    CrcCopyPage(&memregion_pe, &source_pe);
    memregion_pe.pattern = source_pe.pattern;
    if ((sat_->error_injection() || error_injection_) && loops == 2) {
      addr = reinterpret_cast<int64*>(memregion_pe.addr);
      offset = random() % (sat_->page_length() / wordsize_);
      data = addr[offset];
      addr[offset] = error_constant;
    }
    phase_ = kPhaseCheck;
    CrcCheckPage(&memregion_pe);
    phase_ = kPhaseNoPhase;
    result = result && sat_->PutValid(&source_pe);
    if (!result) {
      logprintf(0, "Process Error: memory region thread failed to push "
                "pages into SAT, bailing\n");
      break;
    }
    result = result && pages_->Push(&memregion_pe);
    if (!result) {
      logprintf(0, "Process Error: memory region thread failed to push "
                "pages into queue, bailing\n");
      break;
    }
    if ((sat_->error_injection() || error_injection_) &&
        loops >= 1 && loops <= 2) {
      addr[offset] = data;
    }
    loops++;
    YieldSelf();
  }
  pages_copied_ = loops;
  status_ = result;
  logprintf(9, "Log: Completed %d: Memory Region thread. Status %d, %d "
            "pages checked\n", thread_num_, status_, pages_copied_);
  return result;
}
bool MemoryRegionThread :: Work ( ) { struct page_entry source_pe ; struct page_entry memregion_pe ; bool result = true ; int64 loops = 0 ; const uint64 error_constant = 0x00ba00000000ba00LL ; int64 * addr = 0x0 ; int offset = 0 ; int64 data = 0 ; logprintf ( 9 , " \n " , thread_num_ ) ; while ( IsReadyToRun ( ) ) { phase_ = kPhaseNoPhase ; result = result && sat_ -> GetValid ( & source_pe ) ; if ( ! result ) { logprintf ( 0 , " " " \n " ) ; break ; } result = result && pages_ -> PopRandom ( & memregion_pe ) ; if ( ! result ) { logprintf ( 0 , " " " \n " ) ; break ; } if ( ( sat_ -> error_injection ( ) || error_injection_ ) && loops == 1 ) { addr = reinterpret_cast < int64 * > ( source_pe . addr ) ; offset = random ( ) % ( sat_ -> page_length ( ) / wordsize_ ) ; data = addr [ offset ] ; addr [ offset ] = error_constant ; } phase_ = kPhaseCopy ; CrcCopyPage ( & memregion_pe , & source_pe ) ; memregion_pe . pattern = source_pe . pattern ; if ( ( sat_ -> error_injection ( ) || error_injection_ ) && loops == 2 ) { addr = reinterpret_cast < int64 * > ( memregion_pe . addr ) ; offset = random ( ) % ( sat_ -> page_length ( ) / wordsize_ ) ; data = addr [ offset ] ; addr [ offset ] = error_constant ; } phase_ = kPhaseCheck ; CrcCheckPage ( & memregion_pe ) ; phase_ = kPhaseNoPhase ; result = result && sat_ -> PutValid ( & source_pe ) ; if ( ! result ) { logprintf ( 0 , " " " \n " ) ; break ; } result = result && pages_ -> Push ( & memregion_pe ) ; if ( ! result ) { logprintf ( 0 , " " " \n " ) ; break ; } if ( ( sat_ -> error_injection ( ) || error_injection_ ) && loops >= 1 && loops <= 2 ) { addr [ offset ] = data ; } loops ++ ; YieldSelf ( ) ; } pages_copied_ = loops ; status_ = result ; logprintf ( 9 , " " " \n " , thread_num_ , status_ , pages_copied_ ) ; return result ; }
Workload for testion memory or MMIO regions.
Workload for testion memory or MMIO regions .
// For error injection. // Getting pages from SAT and queue. // Error injection for CRC copy. // Copying SAT page into memory region. // Error injection for CRC Check. // Checking page content in memory region. // Storing pages on their proper queues.