00001 // stats.h 00002 // Data structures for gathering statistics about Nachos performance. 00003 // 00004 // DO NOT CHANGE -- these stats are maintained by the machine emulation 00005 // 00006 // 00007 // Copyright (c) 1992-1993 The Regents of the University of California. 00008 // All rights reserved. See copyright.h for copyright notice and limitation 00009 // of liability and disclaimer of warranty provisions. 00010 00011 #ifndef STATS_H 00012 #define STATS_H 00013 00014 #include "copyright.h" 00015 00016 // The following class defines the statistics that are to be kept 00017 // about Nachos behavior -- how much time (ticks) elapsed, how 00018 // many user instructions executed, etc. 00019 // 00020 // The fields in this class are public to make it easier to update. 00021 00022 class Statistics { 00023 public: 00024 int totalTicks; // Total time running Nachos 00025 int idleTicks; // Time spent idle (no threads to run) 00026 int systemTicks; // Time spent executing system code 00027 int userTicks; // Time spent executing user code 00028 // (this is also equal to # of 00029 // user instructions executed) 00030 00031 int numDiskReads; // number of disk read requests 00032 int numDiskWrites; // number of disk write requests 00033 int numConsoleCharsRead; // number of characters read from the keyboard 00034 int numConsoleCharsWritten; // number of characters written to the display 00035 int numPageFaults; // number of virtual memory page faults 00036 int numPacketsSent; // number of packets sent over the network 00037 int numPacketsRecvd; // number of packets received over the network 00038 00039 Statistics(); // initialize everything to zero 00040 00041 void Print(); // print collected statistics 00042 }; 00043 00044 // Constants used to reflect the relative time an operation would 00045 // take in a real system. A "tick" is a just a unit of time -- if you 00046 // like, a microsecond. 00047 // 00048 // Since Nachos kernel code is directly executed, and the time spent 00049 // in the kernel measured by the number of calls to enable interrupts, 00050 // these time constants are none too exact. 00051 00052 const int UserTick = 1; // advance for each user-level instruction 00053 const int SystemTick = 10; // advance each time interrupts are enabled 00054 const int RotationTime = 500; // time disk takes to rotate one sector 00055 const int SeekTime = 500; // time disk takes to seek past one track 00056 const int ConsoleTime = 100; // time to read or write one character 00057 const int NetworkTime = 100; // time to send or receive one packet 00058 const int TimerTicks = 100; // (average) time between timer interrupts 00059 00060 #endif // STATS_H