-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessorPrinter.py
executable file
·38 lines (31 loc) · 1.25 KB
/
ProcessorPrinter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from Processor import *
class ProcessorPrinter:
########################################################
####### PRINTING FUNCTIONS BELOW THIS LINE #############
proc = None
def __init__(self, processor):
self.proc = processor
def getQStr(self):
s = ""
if (self.proc.workQ.isEmpty()):
s = "[Q <empty>]"
else:
s += "[Q"
for p in self.proc.workQ.queue:
s += " "
s += p.label
s += "]"
return s
def __repr__(self):
return str(vars(self.proc))
def __str__(self):
s = "PROC INFO:\ncSwitchTime : {0} ms\nRunTime : {1} ms\nworkQ Size : {2} processes\n".format(
self.proc.cSwitchTime,
int(self.proc.rTime),
self.proc.workQ.size()) + \
"procPool Size : {0} processes\nalgorithm : {1}\ncProc : {2}\n".format(self.proc.len(self.proc.procPool),
self.proc.algorithm,
self.proc.cProc)
if (not (self.proc.tSlice is None)):
s += "nxtSlice : {0} ms".format(self.proc.nxtSlice)
return s