1 /* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u.hpp"
7 #include <simgrid/plugins/file_system.h>
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
14 simgrid::s4u::ExecPtr bob_compute = simgrid::s4u::this_actor::exec_init(1e9);
15 simgrid::s4u::IoPtr bob_write =
16 simgrid::s4u::Host::current()->get_disks().front()->io_init(4000000, simgrid::s4u::Io::OpType::WRITE);
17 simgrid::s4u::IoPtr carl_read =
18 simgrid::s4u::Host::by_name("carl")->get_disks().front()->io_init(4000000, simgrid::s4u::Io::OpType::READ);
19 simgrid::s4u::ExecPtr carl_compute = simgrid::s4u::Host::by_name("carl")->exec_init(1e9);
21 // Name the activities (for logging purposes only)
22 bob_compute->set_name("bob compute");
23 bob_write->set_name("bob write");
24 carl_read->set_name("carl read");
25 carl_compute->set_name("carl compute");
27 // Create the dependencies:
28 // 'bob_write' is a successor of 'bob_compute'
29 // 'carl_read' is a successor of 'bob_write'
30 // 'carl_compute' is a successor of 'carl_read'
31 bob_compute->add_successor(bob_write);
32 bob_write->add_successor(carl_read);
33 carl_read->add_successor(carl_compute);
35 // Start the activities.
37 bob_write->vetoable_start();
38 carl_read->vetoable_start();
39 carl_compute->vetoable_start();
41 // Wait for their completion (should be replaced by a wait_any_for at some point)
48 int main(int argc, char* argv[])
50 simgrid::s4u::Engine e(&argc, argv);
51 sg_storage_file_system_init();
52 e.load_platform(argv[1]);
54 simgrid::s4u::Actor::create("bob", simgrid::s4u::Host::by_name("bob"), test);
58 XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());