git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7182
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
for i in 0..numberOfTask-1
task = MSG::Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize);
mailbox = "slave " + (i%slaveCount).to_s
for i in 0..numberOfTask-1
task = MSG::Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize);
mailbox = "slave " + (i%slaveCount).to_s
- MSG::info("Master Sending "+ MSG::Task.name(task) + " to " + mailbox + " with Comput Size " +
- MSG::Task.compSize(task).to_s)
+ MSG::info("Master Sending "+ task.name + " to " + mailbox + " with Comput Size " +
+ task.compSize.to_s)
# task.compSize.to_s) # FIXME: This version creates a deadlock. Interesting
# task.compSize.to_s) # FIXME: This version creates a deadlock. Interesting
- MSG::Task.send(task,mailbox)
- MSG::info("Master Done Sending " +MSG::Task.name(task) + " to " + mailbox)
+ task.send(mailbox)
+ MSG::info("Master Done Sending " + task.name + " to " + mailbox)
end
# Sending Finalize MSG::Tasks
end
# Sending Finalize MSG::Tasks
for i in 0..slaveCount-1
mailbox = "slave " + i.to_s
MSG::info("Master Sending Finalize to " + mailbox)
for i in 0..slaveCount-1
mailbox = "slave " + i.to_s
MSG::info("Master Sending Finalize to " + mailbox)
- MSG::Task.send(Task.new("finalize",0,0),mailbox)
+ finalize_task = Task.new("finalize",0,0)
+ finalize_task.send(mailbox)
end
MSG::info("Master : Everything's Done")
end
end
MSG::info("Master : Everything's Done")
end
while true
info("Ready to Receive Task")
task = MSG::Task.receive(mailbox)
while true
info("Ready to Receive Task")
task = MSG::Task.receive(mailbox)
- task_name = MSG::Task.name(task)
MSG::info("Task Received : " + task.name)
if (task_name == "finalize")
MSG::info("Slave" + s_mailbox + "got finalize msg")
break
end
MSG::info("Task Received : " + task.name)
if (task_name == "finalize")
MSG::info("Slave" + s_mailbox + "got finalize msg")
break
end
- MSG::info("Slave " + s_mailbox + " ...Processing" + MSG::Task.name(task))
- MSG::Task.execute(task)
+ MSG::info("Slave " + s_mailbox + " ...Processing" + task.name)
+ task.execute
end
MSG::info("Slave " + s_mailbox + "I'm Done , See You !!")
end
end
MSG::info("Slave " + s_mailbox + "I'm Done , See You !!")
end
# Thread.list.each {|t| p t}
MSG.run
# Thread.list.each {|t| p t}
MSG.run
-MSG.getClock #FIXME: write "puts MSG.getClock" instead
+puts "Simulation time : " + MSG.getClock .to_s
VALUE rb_task_name(VALUE class,VALUE task) {
// Wrap Ruby Value to m_task_t struct
VALUE rb_task_name(VALUE class,VALUE task) {
// Wrap Ruby Value to m_task_t struct
Data_Get_Struct(task, s_m_task_t, tk);
return rb_str_new2(MSG_task_get_name(tk));
}
Data_Get_Struct(task, s_m_task_t, tk);
return rb_str_new2(MSG_task_get_name(tk));
}
@@nextProcessId = 0
# Attributes
@@nextProcessId = 0
# Attributes
- attr_reader :bind, :id, :name, :pargs # Read only
- attr_accessor :properties # R/W
+ attr_reader :bind, :id, :name, :pargs ,:properties# Read only
def initialize(*args)
super(){
def initialize(*args)
super(){
- raise "Bad Number Of arguments to create a a Ruby Process (name,args,prop) " if args.size < 3
+ raise "Bad Number Of arguments to create a Ruby Process (name,args,prop) " if args.size < 3
@schedBegin = Semaphore.new(0)
@schedEnd = Semaphore.new(0)
@schedBegin = Semaphore.new(0)
@schedEnd = Semaphore.new(0)
@name = args[0]
@pargs = args[1]
@properties = args[2]
@name = args[0]
@pargs = args[1]
@properties = args[2]
# main
def main(args)
# To be overriden by childs
# main
def main(args)
# To be overriden by childs
# execute the main code of the process
MSG::debug("Begin execution")
main(@pargs)
# execute the main code of the process
MSG::debug("Begin execution")
main(@pargs)
- processExit(self) # Exit the Native Process
+# processExit(self) # Exit the Native Process
# The Rest of Methods !!! To be Continued ... FIXME: what's missing?
end
# The Rest of Methods !!! To be Continued ... FIXME: what's missing?
end
+############################################
+# Task Extend from the native Class RbTask
+############################################
+class MSG::Task < MSG::RbTask
+
+ def initialize(*args)
+ super()
+ end
+
+ def name
+ super(self)
+ end
+
+ def compSize
+ super(self)
+ end
+
+ def send(mailbox)
+ super(mailbox)
+ end
+
+ def receive(mailbox)
+ super(mailbox)
+ end
+
+ def source
+ super(self)
+ end
+
+ def sender
+ super(self)
+ end
+
+ def listen(t_alias)
+ super(t_alias)
+ end
+
+ def execute
+ super(self)
+ end
+
+ def listenFromHost(t_alias,host)
+ super(t_alias,host)
+ end
+
+end
+
+############################################
+# Host Extend from the native Class RbHost
+############################################
+class MSG::Host < MSG::RbHost
+
+ def getByName(name)
+ super(name)
+ end
+
+ def name
+ super(self)
+ end
+
+ def speed
+ super(self)
+ end
+
+ def getData
+ super(self)
+ end
+
+ def setData(data)
+ super(self,data)
+ end
+
+ def isAvail
+ super(self)
+ end
+
+ def number
+ super()
+ end
+
+end
+
#########################
# Main chunck
#########################
#########################
# Main chunck
#########################
-// Get Clock FIXME: return the double instead of displaying it
-static void msg_get_clock(VALUE class) {
+// Get Clock FIXME: return the double instead of float
+static VALUE msg_get_clock(VALUE class) {
- printf("Simulation time %f\n",MSG_get_clock());
+ return rb_float_new(MSG_get_clock());
rb_define_method(rb_msg,"processExit",(rb_meth)rb_process_exit,1);
//Classes
rb_define_method(rb_msg,"processExit",(rb_meth)rb_process_exit,1);
//Classes
- rb_task = rb_define_class_under(rb_msg,"Task",rb_cObject);
- rb_host = rb_define_class_under(rb_msg,"Host",rb_cObject);
+ rb_task = rb_define_class_under(rb_msg,"RbTask",rb_cObject);
+ rb_host = rb_define_class_under(rb_msg,"RbHost",rb_cObject);
//Task Methods FIXME: Convert to methods
rb_define_module_function(rb_task,"new",(rb_meth)rb_task_new,3);
//Task Methods FIXME: Convert to methods
rb_define_module_function(rb_task,"new",(rb_meth)rb_task_new,3);