Esempio n. 1
0
int ckpt_map(char *node, struct task_struct *tsk, unsigned long area, unsigned long address, void *buf, size_t len)
{
    int ret;
    char name[MAP_PATH_MAX];
    unsigned long off = address - area;

    ckpt_map_addr2str(off, name);
    ret = ckpt_map_setattr(node, tsk, area, name, buf, len);
    log_map(name, area, address, len);
    return ret;
}
Esempio n. 2
0
/* Run a simulation, using the specified environment file.  */
static void
run_one_simulation (struct dirent *env_file)
{
  if (! open_log_file (env_file->d_name))
    return;

  LOG ((LOG_SCREEN | LOG_FILE), "*** Starting simulation %s ***", env_file->d_name);

  /* Parse the environment file.  */
  if (! initialize_from_env_file (env_file))
    return;

  /* Create all agents.  */
  if (! spawn_all_agents ())
    return;

  for (env.current_time = 0;
       env.current_time < env.simulation_length;
       env.current_time++)
    {
      LOG (LOG_FILE, " ");
      LOG ((LOG_SCREEN | LOG_FILE), "Starting Turn %u", env.current_time);
      LOG (LOG_FILE, " ");
      log_map ();
      LOG (LOG_FILE, " ");
      run_one_turn ();
      if (env.alive_agents == NULL)
        {
          LOG ((LOG_SCREEN | LOG_FILE), "  ** All agents have died -- aborting simulation");
          break;
        }
    }

  /* Clean up.  */
  summarize_results ();
  destroy_all_agents ();
  destroy_agent_list (&env.alive_agents);
  destroy_all_predators ();
  destroy_environment ();
  LOG ((LOG_SCREEN | LOG_FILE), "*** End of simulation %s ***\n", env_file->d_name);

  close_log_file ();
}
Esempio n. 3
0
/* Print a summary in the log file at the end of a simulation.  */
static void
summarize_results (void)
{
  agent_list_t *agent_idx;

  LOG (LOG_FILE, "\nMap at end of simulation:");
  log_map ();

  LOG (LOG_FILE, "Summary of agent performance:");
  for (agent_idx = all_agents; agent_idx; agent_idx = agent_idx->next)
    {
      agent_t *agent = agent_idx->agent_data;

      if (agent->energy > 0)
        LOG (LOG_FILE, "%s: %u (energy of %u at end of simulation)", agent->directory_name,
             env.simulation_length + agent->energy, agent->energy);
      else
        LOG (LOG_FILE, "%s: %u (RIP)", agent->directory_name, agent->age_at_death);
    }
}