[Simgrid-user] program structure

Arnaud Legrand Arnaud.Legrand at imag.fr
Mon Jul 4 07:43:22 CEST 2005


Today Leland Hovey wrote:

> Thanks for clarifying the example. It was a little difficult to follow
> because the slave function sent the "processing" message to DEBUG1 instead
> of INFO1, and sent the "done" message to INFO0.

Hey, you're perfectly right. INFO should be used all the time. I have just
corrected it in the CVS. Thanks!

> Next, I need to learn if gridsim can simulate the following:

Tsssss. :) You meant SimGrid, right ? ;)

> Instead of executing tasks to completion, 1 ms snapshots are taken. In
> other words, tasks are submitted to a slave, after 1 ms the slave informs
> the master which of its current tasks completed and which ones didn't,
> then this cycle repeats.
> Any suggestions about how to structure this?

We could do it like that for exemple (I only give you a rough idea and keep
it simple on purpose. You could avoid recreating a new process for each task
by setting up a permanent queue, you could make the task reception
completely asynchronous as well, ...):

/*** struct attached to a task. Put whatever you want in it.  ***/
typedef struct _task_data {
   int done;
} s_task_data_t, *task_data_t;

/*** an asynchronous execution function  ***/
int task_Iexecute(int argc, char **arvv)
   m_task_t task = MSG_process_self()->data;

   ((task_data_t) task->data)->done = 1;

/*** the slave function ***/
int slave(int argc, char **argv)
   while(1) {
     ((task_data_t)task->data)->done = 0;
     MSG_process_create("worker", task_Iexecute, task, MSG_host_self());
     while(1) {
       if(((task_data_t)task->data)->done = 1) {
       send_heart_beat(); /* still working on it! */

Note however that if you do that, it will really slow your simulation
because sending a message every milisecond is very... time consuming. :) But
after all it would not be reasonnable in real life either... ;)

I hope this helps.



More information about the Simgrid-user mailing list