Esempio n. 1
0
def main():
    """Run the test."""
    # Create the logger.
    log_file_name = sys.argv[1] if len(sys.argv) > 1 else '-'
    log_to_file = log_file_name != '-'
    with open(log_file_name, 'xb') if log_to_file else sys.stdout.buffer as log_file:
        binary_log = binarylog.BinaryLog(log_file)

        # Create and run the world.
        the_world = world.World(1, KERNEL.module, binary_log, local_timer_scheduling=False)
        while the_world.step() <= 400:
            pass

        the_world.log_statistics()
Esempio n. 2
0
 def __init__(self,
              cores,
              kernel,
              log=binarylog.BinaryLog(io.BytesIO()),
              *,
              local_timer_scheduling):
     """Create a :class:`World`."""
     if cores > 1:
         raise RuntimeError('Does not support more than 1 core yet.')
     self.cores = [
         cpucore.Core(idx,
                      kernel._scheduler_thread,
                      log,
                      local_timer_scheduling=local_timer_scheduling)
         for idx in range(0, cores)
     ]
     for core in self.cores:
         kernel.register_vcpu(core)
     self.log = log