1 -- Copyright (c) 2011, 2014. The SimGrid Team.
2 -- All rights reserved.
4 -- This program is free software; you can redistribute it and/or modify it
5 -- under the terms of the license (GNU LGPL) which comes with this package.
9 -- Splay global modules
18 -- Splay global variables
21 job.list_type = "random"
25 for i = 1, simgrid.host.number() do
26 job.nodes[i] = { ip = simgrid.host.get_prop_value(simgrid.host.at(i), "ip"),
27 port = simgrid.host.get_prop_value(simgrid.host.at(i), "port") }
37 return simgrid.host.get_prop_value(simgrid.host.self(), "ip")
40 function job.me.port()
41 return simgrid.host.get_prop_value(simgrid.host.self(), "port")
45 function job.position()
46 return simgrid.host.get_prop_value(simgrid.host.self(), "position")
50 function log:print(msg)
55 function rpc.call(node, call)
61 if type(node) == "table" then
62 mailbox = node.ip..":"..node.port
65 if type(call) == "table" then
69 task_call = simgrid.task.new("splay_task", 10000, 10000)
70 task_call['func_call_name'] = func
71 task_call['func_call_arg'] = arg
72 log:print("Sending Task to mailbox "..mailbox.." to call '"..func.."' with arg '"..arg.."'")
73 simgrid.task.send(task_call, mailbox)
77 function rpc.server(port)
78 -- nothing really to do : no need to open Socket since it's a Simulation
82 function events.sleep(time)
83 my_mailbox = job.me.ip()..":"..job.me.port()
84 task = simgrid.task.recv(my_mailbox, time)
87 -- an RPC call just woke me up
88 call_function(task['func_call_name'], task['func_call_arg'])
92 -- main function for each process, this is equivalent to the deployment file
93 function events.thread(main_func)
94 dofile("platform_script.lua")
100 simgrid.host.destroy(simgrid.host.self())
104 function start.loop()
110 function misc.between(a, b)
115 function call_function(fct, arg)
119 function SPLAYschool(arg)
120 simgrid.info("Calling me..."..arg)