tac0S
Template Affectional Command Operating System
stats.h
Go to the documentation of this file.
1 
14 #ifndef STATS_H
15 #define STATS_H
16 
17 #include "copyright.h"
18 
24 
25 class Statistics {
26  public:
27  // LB: type of ticks promoted from 32 bit int to 64 bit long long
28  // to cope with long runs
29  // int totalTicks; // Total time running Nachos
30  // int idleTicks; // Time spent idle (no threads to run)
31  // int systemTicks; // Time spent executing system code
32  // int userTicks; // Time spent executing user code
33  // (this is also equal to # of
34  // user instructions executed)
35  long long totalTicks; // Total time running Nachos
36  long long idleTicks; // Time spent idle (no threads to run)
37  long long systemTicks; // Time spent executing system code
38  long long userTicks; // Time spent executing user code
39  // (this is also equal to # of
40  // user instructions executed)
41  // End of correction
42 
43 
44  int numDiskReads; // number of disk read requests
45  int numDiskWrites; // number of disk write requests
46  int numConsoleCharsRead; // number of characters read from the keyboard
47  int numConsoleCharsWritten; // number of characters written to the display
48  int numPageFaults; // number of virtual memory page faults
49  int numPacketsSent; // number of packets sent over the network
50  int numPacketsRecvd; // number of packets received over the network
51 
52  Statistics(); // initialize everything to zero
53 
54  void Print(); // print collected statistics
55 };
56 
57 // Constants used to reflect the relative time an operation would
58 // take in a real system. A "tick" is a just a unit of time -- if you
59 // like, a microsecond.
60 //
61 // Since Nachos kernel code is directly executed, and the time spent
62 // in the kernel measured by the number of calls to enable interrupts,
63 // these time constants are none too exact.
64 
65 #define UserTick 1 // advance for each user-level instruction
66 #define SystemTick 10 // advance each time interrupts are enabled
67 #define RotationTime 500 // time disk takes to rotate one sector
68 #define SeekTime 500 // time disk takes to seek past one track
69 #define ConsoleTime 100 // time to read or write one character
70 #define NetworkTime 100 // time to send or receive one packet
71 #define TimerTicks 100 // (average) time between timer interrupts
72 
73 #endif // STATS_H
Statistics()
Statistics::Statistics Initialize performance metrics to zero, at system startup. ...
Definition: stats.cc:20
void Print()
Statistics::Print Print performance metrics, when we've finished everything at system shutdown...
Definition: stats.cc:35
The following class defines the statistics that are to be kept about Nachos behavior – how much time...
Definition: stats.h:25