foreach (example actions-comm actions-storage
- actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend
+ actor-create actor-daemon actor-kill actor-migration actor-suspend
+ actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend actor-priority
app-masterworker app-pingpong app-token-ring
async-wait async-waitany async-waitall
plugin-hostload io mutex)
set(examples_src ${examples_src} PARENT_SCOPE)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent.tesh
${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh
+ ${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority.tesh
${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime.tesh
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait.tesh
${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany.tesh
${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/s4u-actions-storage_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/s4u-app-masterworker_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany_d.xml
foreach(example actions-comm actions-storage
actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend
app-bittorrent app-masterworker app-pingpong app-token-ring
- async-wait async-waitall async-waitany
+ async-wait async-waitall async-waitany actor-priority
dht-chord plugin-hostload io mutex)
ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u-${example}.tesh)
endforeach()
Actors can be suspended and resumed during their executions
thanks to the @ref suspend and @ref resume methods.
+ - <b>Priority actors</b>.
+ @ref examples/s4u/actor-priority/s4u-actor-priority.cpp \n
+ Actors can be launched according their priorities thanks to the @ref
+ execution method.
+
- <b>Kill actors</b>.
@ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n
Actors can forcefully stop other actors with the @ref kill method.
--- /dev/null
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/s4u.hpp"
+#include <cstdlib>
+#include <iostream>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+class test {
+ double computation_amount;
+ double priority;
+
+public:
+ explicit test(std::vector<std::string> args)
+{
+ computation_amount = std::stod(args[1]);
+ priority = std::stod(args[2]);
+}
+void operator()()
+{
+ XBT_INFO("Hello! Running an actor of size %g with priority %g", computation_amount, priority);
+ simgrid::s4u::this_actor::execute(computation_amount, priority);
+
+ XBT_INFO("Goodbye now!");
+}
+};
+
+int main(int argc, char *argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+ "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
+
+ e.registerFunction<test>("test");
+
+ e.loadPlatform(argv[1]);
+ e.loadDeployment(argv[2]);
+
+ e.run();
+
+ return 0;
+}
--- /dev/null
+#! ./tesh
+
+! output sort 19
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-priority$EXEEXT ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../s4u/actor-priority/s4u-actor-priority_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:test@Fafard) Hello! Running an actor of size 7.6296e+07 with priority 1
+> [ 0.000000] (2:test@Fafard) Hello! Running an actor of size 7.6296e+07 with priority 2
+> [ 1.500000] (2:test@Fafard) Goodbye now!
+> [ 2.000000] (1:test@Fafard) Goodbye now!
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4.1">
+ <actor host="Fafard" function="test">
+ <argument value="76296000"/>
+ <argument value="1.0"/>
+ </actor>
+ <actor host="Fafard" function="test">
+ <argument value="76296000"/>
+ <argument value="2.0"/>
+ </actor>
+</platform>
/** Block the actor, computing the given amount of flops */
XBT_PUBLIC(void) execute(double flop);
+/** Block the actor, computing the given amount of flops and priority */
+XBT_PUBLIC(void) execute(double flop, double priority);
/** Block the actor until it gets a message from the given mailbox.
*
simcall_execution_wait(s);
}
+void execute(double flops,double priority)
+{
+ smx_activity_t s = simcall_execution_start(nullptr,flops,1 / priority/*priority*/,0./*bound*/);
+ simcall_execution_wait(s);
+}
+
void* recv(MailboxPtr chan) // deprecated
{
return chan->get();