X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/131e40753b3b0da5fa092583cf48fec9d88f46bd..23436dcdc124bde8deb55df96988e7939a39f145:/src/bindings/rubyDag/rb_SD_task.c diff --git a/src/bindings/rubyDag/rb_SD_task.c b/src/bindings/rubyDag/rb_SD_task.c new file mode 100644 index 0000000000..b2dadc4709 --- /dev/null +++ b/src/bindings/rubyDag/rb_SD_task.c @@ -0,0 +1,172 @@ +#include "rb_SD_task.h" + +// Free Method +static void SD_task_free(SD_task_t tk) { +// SD_task_destroy(tk); +} + +static void rb_SD_task_destroy(VALUE class,VALUE task) +{ + SD_task_t tk ; + Data_Get_Struct(task, SD_task_t, tk); + SD_task_destroy(tk); +} +// New Method +static VALUE rb_SD_task_new(VALUE class, VALUE name,VALUE amount) +{ + //data Set to NULL + SD_task_t task = SD_task_create(RSTRING(name)->ptr,NULL,NUM2DBL(amount)); + // Wrap m_task_t to a Ruby Value + return Data_Wrap_Struct(class, 0, SD_task_free, task); + +} + +//Get Name +static VALUE rb_SD_task_name(VALUE class,VALUE task) +{ + // Wrap Ruby Value to m_task_t struct + SD_task_t tk; + Data_Get_Struct(task, SD_task_t, tk); + return rb_str_new2(SD_task_get_name(tk)); + +} + +// Schedule Task +static void rb_SD_task_schedule(VALUE class,VALUE task,VALUE workstation_nb,VALUE workstation_list,VALUE computation_amount,VALUE communication_amount,VALUE rate) +{ + // Wrap Ruby Value to m_task_t struct + int i,wrk_nb,comp_nb,comm_nb; + double *comp_amount,*comm_amount; + double rt; + VALUE *ptr_wrk,*ptr_comp,*ptr_comm; + SD_task_t tk; + Data_Get_Struct(task, SD_task_t, tk); + wrk_nb = NUM2INT(workstation_nb); + comp_nb = RARRAY(computation_amount)->len; + comm_nb = RARRAY(communication_amount)->len; + rt = NUM2DBL(rate); + SD_workstation_t *wrk_list; + + ptr_wrk = RARRAY(workstation_list)->ptr; + ptr_comp = RARRAY(computation_amount)->ptr; + ptr_comm = RARRAY(communication_amount)->ptr; + + wrk_list = xbt_new0(SD_workstation_t,wrk_nb); + comp_amount = xbt_new0(double,wrk_nb);//malloc(sizeof(double)*wrk_nb); //xbt_new0(double,wrk_nb); + comm_amount = xbt_new0(double,wrk_nb);//malloc(sizeof(double)*wrk_nb); //xbt_new0(double,wrk_nb); + + // wrk_nb == comp_nb == comm_nb ??? + for (i=0;iptr; + ptr_comp = RARRAY(computation_amount)->ptr; + ptr_comm = RARRAY(communication_amount)->ptr; + + wrk_list = xbt_new0(SD_workstation_t,wrk_nb); + comp_amount = xbt_new0(double,wrk_nb); + comm_amount = xbt_new0(double,wrk_nb); + + for (i=0;i