Пример #1
0
 def run(self):
     LOG.info('Starting MicroEarthquake for %s',
              Util.stringify_process(self.root_pid))
     if not self.dry_run:
         Util.check_caps()
     while True:
         try:
             self.step()
         except Exception as e:
             LOG.warning('got an exception')
             LOG.exception(e)
Пример #2
0
    def _apply_sched(self, pid, runtime, deadline, period):
        """
        Apply SCHED_DEADLINE(runtime,deadline,period) to pid.
        runtime, deadline, and period are in nanoseconds. see sched_setattr(2).
        Should satisfy runtime <= deadline <= period.
        """
        LOG.info('Applying SCHED_DEADLINE(%f,%f,%f) for %s',
                 runtime / BASE,
                 deadline / BASE,
                 period / BASE,
                 Util.stringify_process(pid))

        if self.dry_run:
            return

        res = _native.lib.sched_setattr_deadline(pid,
                                                 runtime,
                                                 deadline,
                                                 period)
        assert res == 0 or res == -1
        if res < 0:
            LOG.warning(colorama.Back.RED + colorama.Fore.WHITE +
                        'sched_setattr() returned errno %d (%s)' +
                        colorama.Style.RESET_ALL,
                        _native.ffi.errno,
                        os.strerror(_native.ffi.errno))
        return res == 0
Пример #3
0
    def step(self):
        # nop in 1.0 - prob
        if not Util.probab(self.probability):
            return

        pids = Util.get_all_pids_under(self.root_pid)
        random.shuffle(pids)

        scheds = self._choose_scheds(pids)

        applied_count = 0
        for (pid, runtime, deadline, period) in scheds:
            applied = self._apply_sched(pid, runtime, deadline, period)
            if applied:
                applied_count += 1

        LOG.info(colorama.Back.GREEN + colorama.Fore.WHITE +
                 'Applied: %d of %d, #PID=%d' + colorama.Style.RESET_ALL,
                 applied_count, len(scheds), len(pids))
        time.sleep(self.interval)