X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/16dd4462054b2f22e97c7813f57088d5df7c27d4..6760cb07d6b57be16928d95339d71e57c4e24f36:/src/bindings/ruby/MasterSlave.rb diff --git a/src/bindings/ruby/MasterSlave.rb b/src/bindings/ruby/MasterSlave.rb index 1b0344fdb8..7c1ca60a04 100644 --- a/src/bindings/ruby/MasterSlave.rb +++ b/src/bindings/ruby/MasterSlave.rb @@ -10,7 +10,7 @@ include MSG ################################################# class Master < MSG::Process - # main : that function that will be executed when Running Simulation + # main : that function that will be executed when running simulation def main(args) # args is an array containing arguments for function master size = args.size @@ -25,26 +25,24 @@ class Master < MSG::Process slaveCount = Integer(args[3]) # Creates and sends the tasks - for i in 0..numberOfTask-1 + 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 "+ task.name + " to " + mailbox + " with Comput Size " + - task.compSize.to_s) -# task.compSize.to_s) # FIXME: This version creates a deadlock. Interesting - task.send(mailbox) - MSG::info("Master Done Sending " + task.name + " to " + mailbox) - end + mailbox = "slave " + (i%slaveCount).to_s + MSG::debug("Master Sending "+ task.name + " to " + mailbox + " with Comput Size " + + task.compSize.to_s) + task.send(mailbox) + MSG::debug("Master Done Sending " + task.name + " to " + mailbox) + end # Sending Finalize MSG::Tasks + #MSG::info("Master: All "+numberOfTask+" tasks have been dispatched. Let's tell everybody the computation is over.") MSG::info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.") for i in 0..slaveCount-1 mailbox = "slave " + i.to_s - MSG::info("Master Sending Finalize to " + mailbox) finalize_task = Task.new("finalize",0,0) finalize_task.send(mailbox) end MSG::info("Master : Everything's Done") - Thread.list.each {|t| p t} end end @@ -60,18 +58,14 @@ class Slave < MSG::Process end while true - info("Ready to Receive Task") task = MSG::Task.receive(mailbox) - MSG::info("Task Received : " + task.name) if (task.name == "finalize") - MSG::info("Slave " + mailbox + " got finalize msg") break end - MSG::info("Slave " + mailbox + " ...Processing" + task.name) task.execute - MSG::info("task "+ task.name + " Executed !!") + MSG::debug("Slave '" + mailbox + "' done executing task "+ task.name + ".") end - MSG::info("Slave " + mailbox + "I'm Done , See You !!") + MSG::info("I'm done, see you") end end @@ -85,11 +79,8 @@ if (ARGV.length == 2) else MSG.createEnvironment("platform.xml") MSG.deployApplication("deploy.xml") - #Thread.list.each {|t| p t} end MSG.run -Thread.list.each {|t| p t} puts "Simulation time : " + MSG.getClock .to_s - -# exit() +MSG.exit