• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MSG_process_sleep函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MSG_process_sleep函数的典型用法代码示例。如果您正苦于以下问题:C++ MSG_process_sleep函数的具体用法?C++ MSG_process_sleep怎么用?C++ MSG_process_sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MSG_process_sleep函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dream_master

/* The Dream master: */
static int dream_master(int argc, char *argv[])
{
  msg_process_t lazy = NULL;

  XBT_INFO("Let's create a lazy guy."); /* - Create a lazy_guy process */
  lazy = MSG_process_create("Lazy", lazy_guy, NULL, MSG_host_self());
  XBT_INFO("Let's wait a little bit...");
  MSG_process_sleep(10.0);              /* - Wait for 10 seconds */
  XBT_INFO("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!");
  MSG_process_resume(lazy);             /* - Then wake up the lazy_guy */

  MSG_process_sleep(5.0);               /* Repeat two times: */
  XBT_INFO("Suspend the lazy guy while he's sleeping...");
  MSG_process_suspend(lazy);            /* - Suspend the lazy_guy while he's asleep */
  XBT_INFO("Let him finish his siesta.");
  MSG_process_sleep(10.0);              /* - Wait for 10 seconds */
  XBT_INFO("Wake up, lazy guy!");
  MSG_process_resume(lazy);             /* - Then wake up the lazy_guy again */

  MSG_process_sleep(5.0);
  XBT_INFO("Suspend again the lazy guy while he's sleeping...");
  MSG_process_suspend(lazy);
  XBT_INFO("This time, don't let him finish his siesta.");
  MSG_process_sleep(2.0);
  XBT_INFO("Wake up, lazy guy!");
  MSG_process_resume(lazy);

  XBT_INFO("OK, goodbye now.");
  return 0;
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:31,代码来源:process-suspend.c


示例2: sender

/** Sender function  */
int sender(int argc, char *argv[])
{
  long number_of_tasks = atol(argv[1]);
  double task_comp_size = atof(argv[2]);
  double task_comm_size = atof(argv[3]);
  long receivers_count = atol(argv[4]);
  double sleep_start_time = atof(argv[5]);
  double sleep_test_time = atof(argv[6]);

  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
        sleep_test_time);

  msg_comm_t comm = NULL;
  int i;
  m_task_t task = NULL;
  MSG_process_sleep(sleep_start_time);
  for (i = 0; i < number_of_tasks; i++) {
    char mailbox[256];
    char sprintf_buffer[256];

    sprintf(mailbox, "receiver-%ld", i % receivers_count);
    sprintf(sprintf_buffer, "Task_%d", i);

    task =
        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
                        NULL);
    comm = MSG_task_isend(task, mailbox);
    XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);

    if (sleep_test_time == 0) {
      MSG_comm_wait(comm, -1);
    } else {
      while (MSG_comm_test(comm) == 0) {
        MSG_process_sleep(sleep_test_time);
      };
      MSG_comm_destroy(comm);
    }

  }

  for (i = 0; i < receivers_count; i++) {
    char mailbox[80];
    sprintf(mailbox, "receiver-%ld", i % receivers_count);
    task = MSG_task_create("finalize", 0, 0, 0);
    comm = MSG_task_isend(task, mailbox);
    XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
    if (sleep_test_time == 0) {
      MSG_comm_wait(comm, -1);
    } else {
      while (MSG_comm_test(comm) == 0) {
        MSG_process_sleep(sleep_test_time);
      };
      MSG_comm_destroy(comm);
    }

  }

  XBT_INFO("Goodbye now!");
  return 0;
}                               /* end_of_sender */
开发者ID:rosacris,项目名称:simgrid,代码行数:61,代码来源:peer.c


示例3: terrorist

/** Terrorist. This process sends a bunch of exceptions to the victim. */
static int terrorist(int argc, char *argv[])
{
  msg_process_t victim_process = NULL;

  XBT_INFO("Let's create a victim.");
  victim_process = MSG_process_create("victim", victim, NULL, MSG_host_self());

  XBT_INFO("Going to sleep for 1 second");
  if (MSG_process_sleep(1) != MSG_OK)
     xbt_die("What's going on??? I failed to sleep!");
  XBT_INFO("Send a first exception (host failure)");
  SIMIX_process_throw(victim_process, host_error, 0, "First Trick: Let's pretend that the host failed");

  XBT_INFO("Sweet, let's prepare a second trick!");
  XBT_INFO("Going to sleep for 2 seconds");

  if (MSG_process_sleep(2) != MSG_OK)
     xbt_die("What's going on??? I failed to sleep!");
  XBT_INFO("Send a second exception (host failure)");
  SIMIX_process_throw(victim_process, host_error, 0, "Second Trick: Let's pretend again that the host failed");

  XBT_INFO("Sweet, let's prepare a third trick!");
  XBT_INFO("Going to sleep for 3 seconds");

  if (MSG_process_sleep(3) != MSG_OK)
     xbt_die("What's going on??? I failed to sleep!");
  XBT_INFO("Send a third exception (cancellation)");
  SIMIX_process_throw(victim_process, cancel_error, 0, "Third Trick: Let's pretend this time that someone canceled something");

  XBT_INFO("OK, goodbye now.");
  return 0;
}
开发者ID:adegomme,项目名称:simgrid,代码行数:33,代码来源:exception.c


示例4: onoff

static int onoff(int argc, char *argv[]) {
  msg_host_t host1 = MSG_host_by_name("MyHost1");

  XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state"));
  XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  simulate_shutdown(host1);
  XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  simulate_bootup(host1);
  XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  return 0;
}
开发者ID:adegomme,项目名称:simgrid,代码行数:27,代码来源:onoff.c


示例5: test_one_task

static void test_one_task(msg_host_t hostA)
{
  const double cpu_speed = MSG_host_get_speed(hostA);
  const double computation_amount = cpu_speed * 10;
  const char *hostA_name = MSG_host_get_name(hostA);

  XBT_INFO("### Test: with/without MSG_task_set_bound");

  XBT_INFO("### Test: no bound for [email protected]%s", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 0, 0);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 50%% for [email protected]%s", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed / 2);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 33%% for [email protected]%s", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed / 3);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: zero for [email protected]%s (i.e., unlimited)", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, 0);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 200%% for [email protected]%s (i.e., meaningless)", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed * 2);

  MSG_process_sleep(1000);
}
开发者ID:fabienchaix,项目名称:simgrid,代码行数:33,代码来源:cloud-capping.c


示例6: host

static int host(int argc, char *argv[])
{
  char name[2048];
  int id = MSG_process_self_PID();
  snprintf(name,2048,"%s%i", FILENAME1, id);
  msg_file_t file = MSG_file_open(name, NULL);
  XBT_INFO("process %d is writing!", id);
  MSG_file_write(file, 3000000);
  XBT_INFO("process %d goes to sleep for %d seconds", id, id);
  MSG_process_sleep(id);
  XBT_INFO("process %d is writing again!", id);
  MSG_file_write(file, 3000000);
  XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id);
  MSG_process_sleep(6-id);
  XBT_INFO("process %d is reading!", id);
  MSG_file_seek(file, 0, SEEK_SET);
  MSG_file_read(file, 3000000);
  XBT_INFO("process %d goes to sleep for %d seconds", id, id);
  MSG_process_sleep(id);
  XBT_INFO("process %d is reading again!", id);
  MSG_file_seek(file, 0, SEEK_SET);
  MSG_file_read(file, 3000000);

  XBT_INFO("process %d => Size of %s: %llu", id, MSG_file_get_name(file), MSG_file_get_size(file));
  MSG_file_close(file);

  return 0;
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:28,代码来源:concurrent_rw.c


示例7: test

int test(int argc, char **argv){

  MSG_process_sleep(1);

  XBT_INFO("**** Start test ****");
  XBT_INFO("Free after first snapshot");
  
  char *toto = xbt_malloc(5);
  XBT_INFO("Toto allocated");

  void *snap1 = MC_snapshot();

  MSG_process_sleep(1);

  XBT_INFO("First snapshot");

  xbt_free(toto);
  XBT_INFO("Toto free");

  void *snap2 = MC_snapshot();

  XBT_INFO("Second snapshot");

  MSG_process_sleep(1);
  
  MC_ignore_stack("snap2", "test");   
  MC_ignore_stack("snap1", "test");

  XBT_INFO("Test result : %d (0 = state equality, 1 = different states)", MC_compare_snapshots(snap1, snap2));
  
  XBT_INFO("**** End test ****");

  xbt_abort();
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:34,代码来源:snapshot_comparison4.c


示例8: execute_load_test

static int execute_load_test(int argc, char* argv[])
{
  msg_host_t host = MSG_host_by_name("MyHost1");

  XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)",
           MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  double start = MSG_get_clock();
  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);

  XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
           "changed)",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  // Run a task
  start            = MSG_get_clock();
  msg_task_t task1 = MSG_task_create("t1", 100E6, 0, NULL);
  XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
  MSG_task_execute(task1);
  MSG_task_destroy(task1);

  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
           "far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  // ========= Change power peak =========
  int pstate = 2;
  sg_host_set_pstate(host, pstate);
  XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
           MSG_host_get_power_peak_at(host, pstate), MSG_host_get_speed(host));

  // Run a second task
  start = MSG_get_clock();
  task1 = MSG_task_create("t2", 100E6, 0, NULL);
  XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
  MSG_task_execute(task1);
  MSG_task_destroy(task1);
  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
           "far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  start = MSG_get_clock();
  XBT_INFO("========= Requesting a reset of the computation counter");
  sg_host_load_reset(host);
  XBT_INFO("Sleep for 4 seconds");
  MSG_process_sleep(4);
  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  // =========== Turn the other host off ==========
  XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
           MSG_host_get_computed_flops(MSG_host_by_name("MyHost2")));
  MSG_host_off(MSG_host_by_name("MyHost2"));
  start = MSG_get_clock();
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
  return 0;
}
开发者ID:simgrid,项目名称:simgrid,代码行数:60,代码来源:plugin-hostload.c


示例9: emigrant

/** The guy we will move from host to host. It move alone and then is moved by policeman back  */
static int emigrant(int argc, char *argv[])
{
    msg_task_t task;
    XBT_INFO
    ("I'll look for a new job on another machine where the grass is greener.");
    MSG_process_migrate(MSG_process_self(), MSG_get_host_by_name("Boivin"));

    XBT_INFO("Yeah, found something to do");
    task = MSG_task_create("job", 98095000, 0, NULL);
    MSG_task_execute(task);
    MSG_task_destroy(task);
    MSG_process_sleep(2);
    XBT_INFO("Moving back home after work");
    MSG_process_migrate(MSG_process_self(), MSG_get_host_by_name("Jacquelin"));
    MSG_process_migrate(MSG_process_self(), MSG_get_host_by_name("Boivin"));
    MSG_process_sleep(4);
    xbt_mutex_acquire(mutex);
    process_to_migrate = MSG_process_self();
    xbt_cond_broadcast(cond);
    xbt_mutex_release(mutex);
    MSG_process_suspend(MSG_process_self());
    msg_host_t h = MSG_process_get_host(MSG_process_self());
    XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
    XBT_INFO("Uh, nothing to do here. Stopping now");
    return 0;
}                               /* end_of_emigrant */
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:27,代码来源:migration.c


示例10: job_requester

int job_requester(int argc, char* argv[]){
	/**
	   @type simgrid process (run on all tiers)
		Every @timeout checks amount of free (non running) cores.
		If this amount is greater than some N then it sends a job request
		 to scheduler to get new batch of jobs. 

         Simgrid process parameters:
         --------------------------
         None		 
	*/
    std::string host_name = MSG_host_get_name(MSG_host_self());
    std::string CERN = "CERN";
    msg_task_t task = NULL;
    double timeout = 1000;
    long freeCoreAmount;
    int fullCoreAmount = MSG_host_get_core_number(MSG_host_self());
    MSG_process_sleep(0.01);

    while (1){
        freeCoreAmount = fullCoreAmount - xbt_str_parse_int(MSG_host_get_property_value(MSG_host_self(), "activeCore"), "error") -
                xbt_str_parse_int(MSG_host_get_property_value(MSG_host_self(), "corruptedCore"), "error");

        MSG_sem_acquire(sem_requester);
        if (GLOBAL_QUEUE->empty()){
            MSG_sem_release(sem_requester);
            break;
        }

        if (freeCoreAmount > 0){
            JobBatchRequest* jobRequest = new JobBatchRequest;
            jobRequest->coreAmount = freeCoreAmount;

            task = MSG_task_create("request", 0.0, MESSAGES_SIZE, jobRequest);

            plusLinkCounter(host_name, CERN);
            msg_error_t err = MSG_task_send(task, "scheduler");

            switch(err){
                case MSG_OK:
                    minusLinkCounter(host_name, CERN);
                    break;
                case MSG_TRANSFER_FAILURE:
                    minusLinkCounter(host_name, CERN);
                    MSG_task_destroy(task);
                    task = NULL;
                    break;
                case MSG_HOST_FAILURE:
                    MSG_task_destroy(task);
                    task = NULL;
                    break;
            }
        }else MSG_sem_release(sem_requester);

        MSG_process_sleep(timeout);
    }
    return 0;
}
开发者ID:skygrid,项目名称:grid_simulation,代码行数:58,代码来源:job_requester.cpp


示例11: victim

/** Victim. This process gets a lot of remote exceptions  */
static int victim(int argc, char *argv[]) {

  xbt_ex_t e;
  msg_error_t res = MSG_OK;
  
  XBT_INFO("Let's work.");
  TRY {	
    res = MSG_task_execute(MSG_task_create("Task", 1e14, 0, NULL));
    if (res != MSG_OK) {
      XBT_INFO("The MSG_task_execute caught the exception for me and returned %d)",res);
    } else {
      xbt_die("I was expecting an exception during my execution!");
    }
  } CATCH(e) {
    XBT_INFO("The received exception resumed my execution. Good. Here is it:  ----------------------->8----");
    xbt_ex_display(&e);
    XBT_INFO("(end of the first exception) ----8<------------------------");
    xbt_ex_free(e);
  }


  XBT_INFO("Let's get suspended.");
  int gotit = 0;
  TRY {
    MSG_process_suspend(MSG_process_self());
  } CATCH(e) {
    XBT_INFO("The received exception resumed my suspension. Good. Here is it:  ----------------------->8----");
    xbt_ex_display(&e);
    XBT_INFO("(end of the second exception) ----8<------------------------");
    gotit = 1;
    xbt_ex_free(e);
  }
  if(!gotit) {
    xbt_die("I was expecting an exception during my suspension!");
  }
  
  XBT_INFO("Let's sleep for 10 seconds.");
  TRY {
    res = MSG_process_sleep(10);
    if (res != MSG_OK) {
      XBT_INFO("The MSG_process_sleep caught the exception for me and returned %d)",res);
    } else {
      xbt_die("I was expecting to get an exception during my nap.");
    }
  } CATCH(e) {
    XBT_INFO("Got the second exception:   ----------------------->8----");
    xbt_ex_display(&e);
    XBT_INFO("(end of the third exception) ----8<------------------------");
    xbt_ex_free(e);
  }

  XBT_INFO("Let's try a last time to do something on something");
  MSG_process_sleep(10);

  XBT_INFO("That's enough now. I quit.");
  
  return 0;
}
开发者ID:apargupta,项目名称:simgrid,代码行数:59,代码来源:exception.c


示例12: master_main

static int master_main(int argc, char* argv[])
{
  msg_host_t pm0 = MSG_host_by_name("Fafard");
  msg_host_t pm1 = MSG_host_by_name("Tremblay");
  msg_host_t pm2 = MSG_host_by_name("Bourassa");

  msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
  MSG_vm_start(vm0);

  XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
  vm_migrate(vm0, pm1);

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_set_ramsize(vm0, 1e8); // 100Mbytes
  MSG_vm_start(vm0);

  XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
  vm_migrate(vm0, pm1);

  MSG_vm_destroy(vm0);

  vm0          = MSG_vm_create_core(pm0, "VM0");
  msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");

  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
  MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
  vm_migrate_async(vm0, pm1);
  vm_migrate_async(vm1, pm1);
  MSG_process_sleep(10000);

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  vm1 = MSG_vm_create_core(pm0, "VM1");

  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
  MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  XBT_INFO("Test: Migrate two VMs at once to different PMs");
  vm_migrate_async(vm0, pm1);
  vm_migrate_async(vm1, pm2);
  MSG_process_sleep(10000);

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);

  return 0;
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:58,代码来源:cloud-migration.c


示例13: sender

/* Sender process expects 6 arguments: */
static int sender(int argc, char *argv[])
{
  long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");        /* - number of tasks */
  double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - computational cost */
  double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /* - communication cost */
  long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s");    /* - number of receivers */
  double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); /* - start time */
  double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s");         /* - test time */

  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);

  int i;
  msg_task_t task = NULL;
  msg_comm_t comm = NULL;
  MSG_process_sleep(sleep_start_time);
  for (i = 0; i < number_of_tasks; i++) {
    char mailbox[256];
    char snprintf_buffer[256];

    snprintf(mailbox,255, "receiver-%ld", i % receivers_count);
    snprintf(snprintf_buffer,255, "Task_%d", i);

    /* This process first creates a task and send it asynchronously with @ref MSG_task_isend. Then, if: */
    task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size, NULL);
    comm = MSG_task_isend(task, mailbox);
    XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);

    if (sleep_test_time > 0) { /* - "test_time" is set to 0, wait on @ref MSG_comm_wait */
      while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
        MSG_process_sleep(sleep_test_time);
      };
    } else {
      MSG_comm_wait(comm, -1);
    }
    MSG_comm_destroy(comm);
  }

  for (i = 0; i < receivers_count; i++) {
    char mailbox[80];
    snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
    task = MSG_task_create("finalize", 0, 0, 0);
    comm = MSG_task_isend(task, mailbox);
    XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
    if (sleep_test_time > 0) {
      while (MSG_comm_test(comm) == 0) {
        MSG_process_sleep(sleep_test_time);
      }
    } else {
      MSG_comm_wait(comm, -1);
    }
    MSG_comm_destroy(comm);
  }

  XBT_INFO("Goodbye now!");
  return 0;
}
开发者ID:luizabeltrame,项目名称:simgrid,代码行数:57,代码来源:async-wait.c


示例14: slave

static int slave(int argc, char *argv[])
{
    MSG_process_sleep(.5);
    XBT_INFO("Slave started (PID:%d, PPID:%d)", MSG_process_self_PID(), MSG_process_self_PPID());
    while(1) {
        XBT_INFO("Plop i am %ssuspended", (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
        MSG_process_sleep(1);
    }
    XBT_INFO("I'm done. See you!");
    return 0;
}
开发者ID:glesserd,项目名称:simgrid,代码行数:11,代码来源:process.c


示例15: client

static int client(int argc, char *argv[])
{
  int my_pid = MSG_process_get_PID(MSG_process_self());

  char *my_mailbox = xbt_strdup(argv[1]);
  msg_task_t grant = NULL, release = NULL;

  while(1){
    XBT_INFO("Ask the request");
    MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox), "coordinator");

    if(strcmp(my_mailbox, "1") == 0){
      r = 1;
      cs = 0;
      XBT_INFO("Propositions changed : r=1, cs=0");
    }

    MSG_task_receive(&grant, my_mailbox);
    const char *kind = MSG_task_get_name(grant);

    if((strcmp(my_mailbox, "1") == 0) && (strcmp("grant", kind) == 0)){
      cs = 1;
      r = 0;
      XBT_INFO("Propositions changed : r=0, cs=1");
    }

    MSG_task_destroy(grant);
    grant = NULL;
    kind = NULL;

    XBT_INFO("%s got the answer. Sleep a bit and release it", argv[1]);

    MSG_process_sleep(1);

    release = MSG_task_create("release", 0, 1000, NULL);
    MSG_task_send(release, "coordinator");

    release = NULL;

    MSG_process_sleep(my_pid);

    if(strcmp(my_mailbox, "1") == 0){
      cs=0;
      r=0;
      XBT_INFO("Propositions changed : r=0, cs=0");
    }
    
  }
  return 0;
}
开发者ID:glesserd,项目名称:simgrid,代码行数:50,代码来源:bugged1_liveness.c


示例16: receiver

/** Receiver function  */
int receiver(int argc, char *argv[])
{
  m_task_t task = NULL;
  MSG_error_t res;
  int id = -1;
  char mailbox[80];
  msg_comm_t res_irecv;
  double sleep_start_time = atof(argv[2]);
  double sleep_test_time = atof(argv[3]);
  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
        sleep_test_time);

  int read;
  read = sscanf(argv[1], "%d", &id);
  xbt_assert(read,
              "Invalid argument %s\n", argv[1]);

  MSG_process_sleep(sleep_start_time);

  sprintf(mailbox, "receiver-%d", id);
  while (1) {
    res_irecv = MSG_task_irecv(&(task), mailbox);
    XBT_INFO("Wait to receive a task");

    if (sleep_test_time == 0) {
      res = MSG_comm_wait(res_irecv, -1);
      xbt_assert(res == MSG_OK, "MSG_task_get failed");
    } else {
      while (MSG_comm_test(res_irecv) == 0) {
        MSG_process_sleep(sleep_test_time);
      };
      MSG_comm_destroy(res_irecv);
    }

    XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
    if (!strcmp(MSG_task_get_name(task), "finalize")) {
      MSG_task_destroy(task);
      break;
    }

    XBT_INFO("Processing \"%s\"", MSG_task_get_name(task));
    MSG_task_execute(task);
    XBT_INFO("\"%s\" done", MSG_task_get_name(task));
    MSG_task_destroy(task);
    task = NULL;
  }
  XBT_INFO("I'm done. See you!");
  return 0;
}                               /* end_of_receiver */
开发者ID:rosacris,项目名称:simgrid,代码行数:50,代码来源:peer.c


示例17: master

static int master(int argc, char *argv[])
{
  msg_process_t process;

  XBT_INFO("Start slave");
  process =  MSG_process_create("slave from master", slave, NULL, MSG_host_self());
  XBT_INFO("Join the slave (timeout 2)");
  MSG_process_join(process, 2);

  XBT_INFO("Start slave");
  process =  MSG_process_create("slave from master", slave, NULL, MSG_host_self());
  XBT_INFO("Join the slave (timeout 4)");
  MSG_process_join(process, 4);

  XBT_INFO("Start slave");
  process =  MSG_process_create("slave from master", slave, NULL, MSG_host_self());
  XBT_INFO("Join the slave (timeout 2)");
  MSG_process_join(process, 2);

  XBT_INFO("Goodbye now!");

  MSG_process_sleep(1);

  XBT_INFO("Goodbye now!");
  return 0;
}
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:26,代码来源:process_join.c


示例18: worker

static int worker(int argc, char *argv[])
{
  while (1) {
    msg_task_t task = NULL;
    XBT_ATTRIB_UNUSED int res = MSG_task_receive(&(task), "worker_mailbox");
    xbt_assert(res == MSG_OK, "MSG_task_get failed");
    XBT_INFO("Handling task \"%s\"", MSG_task_get_name(task));

    if (!strcmp(MSG_task_get_name(task), "finalize")) {
      XBT_INFO("Destroying task \"%s\"", task->name);
      MSG_task_destroy(task);
      break;
    }

    if (!strcmp(MSG_task_get_name(task), "cancel")) {
      MSG_process_create("worker1", worker_main, task, MSG_host_self());
      MSG_process_sleep(0.1);
      XBT_INFO("Canceling task \"%s\"", task->name);
      MSG_task_cancel(task);
      continue;
    }

    double start = MSG_get_clock();
    MSG_task_execute(task);
    double end = MSG_get_clock();
    XBT_INFO("Task \"%s\" done in %f (amount %f)", MSG_task_get_name(task), end - start,
             MSG_task_get_flops_amount(task));

    MSG_task_destroy(task);
  }
  XBT_INFO("I'm done. See you!");
  return 0;
}
开发者ID:fabienchaix,项目名称:simgrid,代码行数:33,代码来源:task_destroy_cancel.cpp


示例19: simcreat

static void simcreat(const char *const *action) {
  const char *processid = action[0];
  const char *worktime = action[3];
  double sleeptime;
  const char *index = action[4];
  char full_name[1024];
  msg_file_t file = NULL;
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
  sleeptime = atof(worktime);
  MSG_process_sleep(sleeptime);
  //open slow file
  const char *file_name = action[2];
  char fn[200];
   strcpy(fn,file_name);
  ReplaceStr(fn,"/home","/slow");
  sprintf(full_name, "%s:%s:%s:%s","slow",file_name,MSG_process_get_name(MSG_process_self()), index);
  ACT_DEBUG("Entering Creat: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(fn, NULL);
  xbt_dict_set(opened_files, full_name, file, NULL);
  //open fast version of file
  strcpy(fn,file_name);
  ReplaceStr(fn,"/home","/fast");
  sprintf(full_name, "%s:%s:%s:%s","fast",file_name,MSG_process_get_name(MSG_process_self()), index);
  ACT_DEBUG("Entering Creat: %s (filename: %s)", NAME, file_name);
  file = MSG_file_open(fn, NULL);
  xbt_dict_set(opened_files, full_name, file, NULL);
  
  log_action(action, MSG_get_clock() - clock);
  XBT_INFO("creat worker %s %s is done",processid,index);
}
开发者ID:congfairy,项目名称:simulator-fits-,代码行数:30,代码来源:extracttrace.c


示例20: master

static int master(int argc, char *argv[])
{
  XBT_INFO("Hello!");
  MSG_process_sleep(10.0);
  XBT_INFO("OK, goodbye now.");
  return 0;
}                               /* end_of_dram_master */
开发者ID:cemsbr,项目名称:simgrid,代码行数:7,代码来源:sk_time.c



注:本文中的MSG_process_sleep函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MSG_task_create函数代码示例发布时间:2022-05-30
下一篇:
C++ MSG_process_self函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap