init: init nachos hw01, should pass jenkins os_group_20_hw job but fail on os_group_20_ta job

This commit is contained in:
TA
2024-09-19 18:59:13 +08:00
commit 6ad2fa368f
267 changed files with 71977 additions and 0 deletions

45
code/machine/stats.cc Normal file
View File

@@ -0,0 +1,45 @@
// stats.h
// Routines for managing statistics about Nachos performance.
//
// DO NOT CHANGE -- these stats are maintained by the machine emulation.
//
// Copyright (c) 1992-1996 The Regents of the University of California.
// All rights reserved. See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.
#include "copyright.h"
#include "debug.h"
#include "stats.h"
//----------------------------------------------------------------------
// Statistics::Statistics
// Initialize performance metrics to zero, at system startup.
//----------------------------------------------------------------------
Statistics::Statistics()
{
totalTicks = idleTicks = systemTicks = userTicks = 0;
numDiskReads = numDiskWrites = 0;
numConsoleCharsRead = numConsoleCharsWritten = 0;
numPageFaults = numPacketsSent = numPacketsRecvd = 0;
}
//----------------------------------------------------------------------
// Statistics::Print
// Print performance metrics, when we've finished everything
// at system shutdown.
//----------------------------------------------------------------------
void
Statistics::Print()
{
cout << "Ticks: total " << totalTicks << ", idle " << idleTicks;
cout << ", system " << systemTicks << ", user " << userTicks <<"\n";
cout << "Disk I/O: reads " << numDiskReads;
cout << ", writes " << numDiskWrites << "\n";
cout << "Console I/O: reads " << numConsoleCharsRead;
cout << ", writes " << numConsoleCharsWritten << "\n";
cout << "Paging: faults " << numPageFaults << "\n";
cout << "Network I/O: packets received " << numPacketsRecvd;
cout << ", sent " << numPacketsSent << "\n";
}