Esempio n. 1
0
int master(int argc, char *argv[])
{
  const char *hostname = MSG_host_get_name(MSG_host_self());
  int i;

  //the hostname has an empty HDD with a capacity of 100000 (bytes)
  TRACE_host_variable_set(hostname, "HDD_capacity", 100000);
  TRACE_host_variable_set(hostname, "HDD_utilization", 0);

  for (i = 0; i < 10; i++) {
    //create and execute a task just to make the simulated time advance
    msg_task_t task = MSG_task_create("task", 10000, 0, NULL);
    MSG_task_execute (task);
    MSG_task_destroy (task);

    //ADD: after the execution of this task, the HDD utilization increases by 100 (bytes)
    TRACE_host_variable_add(hostname, "HDD_utilization", 100);
  }

  for (i = 0; i < 10; i++) {
    //create and execute a task just to make the simulated time advance
    msg_task_t task = MSG_task_create("task", 10000, 0, NULL);
    MSG_task_execute (task);
    MSG_task_destroy (task);

    //SUB: after the execution of this task, the HDD utilization decreases by 100 (bytes)
    TRACE_host_variable_sub(hostname, "HDD_utilization", 100);
  }
  return 0;
}
Esempio n. 2
0
int addDatasetAmountT(std::string& host_name, std::string& type){
    /**
        Increases number of datasets on @host_name by one.

        Parameters:
        ----------
        @host_name -- name of host
        @type -- DISK or TAPE
    */
    MSG_sem_acquire(sem_link);
    // O -- Tape
    if (!type.compare("0")){
        TRACE_host_variable_add(host_name.c_str(), "datasetOnTape", 1);
        //TRACE_host_variable_set(host_name, "datasetOnTape", dataset_number(host_name, "0"));
    }else{
        TRACE_host_variable_add(host_name.c_str(), "datasetOnDisk", 1);
        //TRACE_host_variable_set(host_name, "datasetOnDisk", dataset_number(host_name, "1"));
    }

    MSG_sem_release(sem_link);
    return 0;
}
static int worker(int argc, char *argv[])
{
  msg_task_t task = NULL;

  TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_worker", 1);
  TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "task_computation", 0);
  while (1) {
    MSG_task_receive(&(task), "master_mailbox");

    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
      MSG_task_destroy(task);
      break;
    }
    //adding the value returned by MSG_task_get_compute_duration(task)
    //to the variable "task_computation"
    TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()), "task_computation", MSG_task_get_flops_amount(task));
    MSG_task_execute(task);
    MSG_task_destroy(task);
    task = NULL;
  }
  return 0;
}
Esempio n. 4
0
/** Receiver function  */
int slave(int argc, char *argv[])
{
  m_task_t task = NULL;
  int res;

  TRACE_host_variable_set("is_slave", 1);
  while (1) {
    res = MSG_task_receive(&(task), "master_mailbox");

    if (!strcmp(MSG_task_get_name(task), "finalize")) {
      MSG_task_destroy(task);
      break;
    }
    //adding the value returned by MSG_task_get_compute_duration(task)
    //to the variable "task_computation"
    TRACE_host_variable_add("task_computation",
                            MSG_task_get_compute_duration(task));
    MSG_task_execute(task);
    MSG_task_destroy(task);
    task = NULL;
  }
  return 0;
}