summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-02-10 00:24:14 -0500
committerMac Mollison <mollison@cs.unc.edu>2010-02-10 00:24:14 -0500
commitcfb9db951084524ca8bb66ce05583a4eaa3383a6 (patch)
tree5fca7817dd1220025fc9dbd179881c25b8c57263
parent813dfe145ee2338702f4f176790dae3b673f30e0 (diff)
Add sanitizer module to sanitize goofy sched_trace input
-rwxr-xr-xrun.py2
-rw-r--r--sanitizer.py46
2 files changed, 48 insertions, 0 deletions
diff --git a/run.py b/run.py
index 3d7e2ab..4db5c0a 100755
--- a/run.py
+++ b/run.py
@@ -13,6 +13,7 @@
13############################################################################### 13###############################################################################
14 14
15import trace_reader 15import trace_reader
16import sanitizer
16import stdout_printer 17import stdout_printer
17 18
18############################################################################### 19###############################################################################
@@ -31,4 +32,5 @@ g6 = [
31############################################################################### 32###############################################################################
32 33
33stream = trace_reader.trace_reader(g6) 34stream = trace_reader.trace_reader(g6)
35stream = sanitizer.sanitizer(stream)
34stdout_printer.stdout_printer(stream) 36stdout_printer.stdout_printer(stream)
diff --git a/sanitizer.py b/sanitizer.py
new file mode 100644
index 0000000..d1764dd
--- /dev/null
+++ b/sanitizer.py
@@ -0,0 +1,46 @@
1###############################################################################
2# Description
3###############################################################################
4
5# Sanitize input. (There are a number of goofy issues with the sched_trace
6# output.)
7
8###############################################################################
9# Public functions
10###############################################################################
11
12def sanitizer(stream):
13 jobs_released = []
14 for record in stream:
15
16 # All records with job < 2 are garbage
17 if record.job < 2:
18 continue
19
20 # Some records with job == 2 are garbage
21 if record.job==2:
22
23 # There is a duplicate release of every job 2
24 # This will throw away the second one
25 if (record.type_name == 'release' and
26 (record.pid,record.job) in jobs_released):
27 continue
28
29 # Job 2 has a resume that is garbage
30 if record.type_name == 'resume':
31 continue
32
33 # Record job releases. This helps with filtering out
34 # the second release of job 2 and renumbering final switch_aways
35 # (see below).
36 if record.type_name == 'release':
37 jobs_released.append((record.pid,record.job))
38
39 # By default, the switch_away for a job (after it has completed)
40 # is maked as being for job+1, which has not been released.
41 # Correct this.
42 if record.type_name == 'switch_away':
43 if (record.pid,record.job) not in jobs_released:
44 record.job -= 1
45
46 yield record