1 /* Copyright (c) 2006-2015. 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.h"
8 using namespace simgrid;
11 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
13 class Worker : Process {
15 Worker(const char*procname, Host *host,int argc, char **argv)
16 : s4u::Process(procname,host,argc,argv){}
18 int main(int argc, char **argv) {
19 XBT_INFO("Hello s4u, I'm ready to serve");
21 char *msg = recvstr(*Channel::byName("worker"));
22 XBT_INFO("I received '%s'",msg);
23 XBT_INFO("I'm done. See you.");
28 class Master : Process {
30 Master(const char*procname, Host *host,int argc, char **argv)
31 : Process(procname,host,argc,argv){}
33 int main(int argc, char **argv) {
34 XBT_INFO("Hello s4u, I have something to send");
35 sendstr(*Channel::byName("worker"),"GaBuZoMeu");
37 XBT_INFO("I'm done. See you.");
43 int main(int argc, char **argv) {
44 Engine *e = new Engine(&argc,argv);
45 e->loadPlatform("../../platforms/two_hosts_platform.xml");
47 new Worker("worker", Host::byName("host0"), 0, NULL);
48 new Master("master", Host::byName("host1"), 0, NULL);