Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reverting Mt's modifications and making use of the brand new SURF timer.
[simgrid.git] / src / msg / global.c
index 9160e07..2fbf288 100644 (file)
@@ -325,7 +325,6 @@ MSG_error_t MSG_main(void)
   while (1) {
     xbt_context_empty_trash();
     while ((process = xbt_fifo_pop(msg_global->process_to_run))) {
-/*       fprintf(stderr,"-> %s (%d)\n",process->name, process->simdata->PID); */
       DEBUG3("Scheduling  %s(%d) on %s",            
             process->name,process->simdata->PID,
             process->simdata->host->name);
@@ -351,6 +350,31 @@ MSG_error_t MSG_main(void)
       surf_action_t action = NULL;
       surf_resource_t resource = NULL;
       m_task_t task = NULL;
+
+      void *fun = NULL;
+      void *arg = NULL;
+      while (surf_timer_resource->extension_public->get(&fun,(void*)&arg)) {
+       DEBUG2("got %p %p", fun, arg);
+       if(fun==MSG_process_create_with_arguments) {
+         process_arg_t args = arg;
+         DEBUG2("Launching %s on %s", args->name, args->host->name);
+         process = MSG_process_create_with_arguments(args->name, args->code, 
+                                                     args->data, args->host,
+                                                     args->argc,args->argv);
+         if(args->kill_time > MSG_getClock()) {
+           surf_timer_resource->extension_public->set(args->kill_time, 
+                                                      (void*) &MSG_process_kill,
+                                                      (void*) process);
+         }
+         xbt_free(args);
+       }
+       if(fun==MSG_process_kill) {
+         process = arg;
+         DEBUG3("Killing %s(%d) on %s", process->name, process->simdata->PID, 
+                process->simdata->host->name);
+         MSG_process_kill(process);
+       }
+      }
       
       xbt_dynar_foreach(resource_list, i, resource) {
        while ((action =