Ejemplo n.º 1
0
 def num_ctx_switches(self):
     vol = unvol = None
     f = open("/proc/%s/status" % self.pid, "rb")
     VOLUNTARY = b("voluntary_ctxt_switches")
     NON_VOLUNTARY = b("nonvoluntary_ctxt_switches")
     try:
         for line in f:
             if line.startswith(VOLUNTARY):
                 vol = int(line.split()[1])
             elif line.startswith(NON_VOLUNTARY):
                 unvol = int(line.split()[1])
             if vol is not None and unvol is not None:
                 return _common.pctxsw(vol, unvol)
         raise NotImplementedError(
             "'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'"
             "fields were not found in /proc/%s/status; the kernel is "
             "probably older than 2.6.23" % self.pid)
     finally:
         f.close()
Ejemplo n.º 2
0
 def num_ctx_switches(self):
     vol = unvol = None
     f = open("/proc/%s/status" % self.pid, "rb")
     VOLUNTARY = b("voluntary_ctxt_switches")
     NON_VOLUNTARY = b("nonvoluntary_ctxt_switches")
     try:
         for line in f:
             if line.startswith(VOLUNTARY):
                 vol = int(line.split()[1])
             elif line.startswith(NON_VOLUNTARY):
                 unvol = int(line.split()[1])
             if vol is not None and unvol is not None:
                 return _common.pctxsw(vol, unvol)
         raise NotImplementedError(
             "'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'"
             "fields were not found in /proc/%s/status; the kernel is "
             "probably older than 2.6.23" % self.pid)
     finally:
         f.close()
Ejemplo n.º 3
0
 def num_ctx_switches(self):
     return _common.pctxsw(*cext.proc_num_ctx_switches(self.pid))
Ejemplo n.º 4
0
 def num_ctx_switches(self):
     return _common.pctxsw(*cext.proc_num_ctx_switches(self.pid))
Ejemplo n.º 5
0
 def num_ctx_switches(self):
     tupl = cext.proc_num_ctx_switches(self.pid)
     return _common.pctxsw(*tupl)
Ejemplo n.º 6
0
 def num_ctx_switches(self):
     tupl = cext.proc_num_ctx_switches(self.pid)
     return _common.pctxsw(*tupl)