include examples/cpp/exec-waitfor/s4u-exec-waitfor.tesh
include examples/cpp/io-async/s4u-io-async.cpp
include examples/cpp/io-async/s4u-io-async.tesh
-include examples/cpp/io-basic/s4u-io-basic.cpp
-include examples/cpp/io-basic/s4u-io-basic.tesh
include examples/cpp/io-degradation/s4u-io-degradation.cpp
include examples/cpp/io-degradation/s4u-io-degradation.tesh
include examples/cpp/io-dependent/s4u-io-dependent.cpp
include examples/cpp/io-file-remote/s4u-io-file-remote_d.xml
include examples/cpp/io-file-system/s4u-io-file-system.cpp
include examples/cpp/io-file-system/s4u-io-file-system.tesh
+include examples/cpp/io-priority/s4u-io-priority.cpp
+include examples/cpp/io-priority/s4u-io-priority.tesh
include examples/cpp/maestro-set/s4u-maestro-set.cpp
include examples/cpp/maestro-set/s4u-maestro-set.tesh
include examples/cpp/mc-bugged1-liveness/promela_bugged1_liveness
maestro-set
mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert
network-wifi
- io-async io-basic io-degradation io-file-system io-file-remote io-disk-raw io-dependent
+ io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
platform-failures platform-profile platform-properties
plugin-host-load plugin-link-load plugin-prodcons
replay-comm replay-io
+++ /dev/null
-#!/usr/bin/env tesh
-
-$ ${bindir:=.}/s4u-io-basic ${platfdir}/hosts_with_disks.xml
-> [bob:privileged_writer:(2) 0.150000] [s4u_test/INFO] Done.
-> [bob:writer:(1) 0.200000] [s4u_test/INFO] Done.
std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
/* - Write 4,000,000 bytes on Disk1 */
disk_list.front()->write(4000000);
- XBT_INFO("Done.");
+ XBT_INFO("First write done.");
+ /* - Write 4,000,000 bytes on Disk1 again */
+ disk_list.front()->write(4000000);
+ XBT_INFO("Second write done.");
}
static void privileged_writer()
*
* So instead of a half/half sharing between the two, we get a 1/3 vs. 2/3 sharing. */
disk_list.front()->io_init(4000000, simgrid::s4u::Io::OpType::WRITE)->set_priority(2)->wait();
- XBT_INFO("Done.");
+ XBT_INFO("First write done.");
/* Note that the timings printed when running this example are a bit misleading, because the uneven sharing only last
* until the privileged actor ends. After this point, the unprivileged one gets 100% of the disk and finishes quite
* quickly. */
+
+ /* Resynchronize actors before second write */
+ simgrid::s4u::this_actor::sleep_for(0.05);
+
+ /* - Write 4,000,000 bytes on Disk1 again and this time :
+ * - Start the I/O operation asynchronously to get an IoPtr
+ * - Let the actor sleep while half of the data is written
+ * - Double its priority
+ * - Wait for the end of the I/O operation
+ *
+ * Writing the second half of the data with a higher priority, and thus 2/3 of the bandwidth takes 0.075s.
+ * In the meantime, the regular writer has only 1/3 of the bandwidth and thus only writes 1MB. After the completion
+ * of the I/O initiated by the privileged writer, the regular writer has the full bandwidth available and only needs
+ * 0.025s to write the last MB.
+ */
+
+ simgrid::s4u::IoPtr io = disk_list.front()->write_async(4000000);
+ simgrid::s4u::this_actor::sleep_for(0.1);
+ XBT_INFO("Increase priority for the priviledged writer (%.0f bytes remaining to write)", io->get_remaining());
+ io->update_priority(2);
+ io->wait();
+ XBT_INFO("Second write done.");
}
int main(int argc, char* argv[])
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-io-priority ${platfdir}/hosts_with_disks.xml
+> [bob:privileged_writer:(2) 0.150000] [s4u_test/INFO] First write done.
+> [bob:writer:(1) 0.200000] [s4u_test/INFO] First write done.
+> [bob:privileged_writer:(2) 0.300000] [s4u_test/INFO] Increase priority for the priviledged writer (2000000 bytes remaining to write)
+> [bob:privileged_writer:(2) 0.375000] [s4u_test/INFO] Second write done.
+> [bob:writer:(1) 0.400000] [s4u_test/INFO] Second write done.
IoPtr set_size(sg_size_t size);
IoPtr set_op_type(OpType type);
+ IoPtr update_priority(double priority);
+
bool is_assigned() const override;
};
return *this;
}
+IoImpl& IoImpl::update_sharing_penalty(double sharing_penalty)
+{
+ sharing_penalty_ = sharing_penalty;
+ surf_action_->set_sharing_penalty(sharing_penalty);
+ return *this;
+}
+
IoImpl& IoImpl::set_timeout(double timeout)
{
const s4u::Host* host = get_disk()->get_host();
IoImpl& set_type(s4u::Io::OpType type);
IoImpl& set_disk(resource::DiskImpl* disk);
+ IoImpl& update_sharing_penalty(double sharing_penalty);
+
sg_size_t get_performed_ioops() const { return performed_ioops_; }
resource::DiskImpl* get_disk() const { return disk_; }
bool enabling_var = (penalty > 0 && var->sharing_penalty_ <= 0);
bool disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0);
- XBT_IN("(sys=%p, var=%p, penalty=%f)", this, var, penalty);
+ XBT_IN("(sys=%p, var=%p, var->sharing_penalty = %f, penalty=%f)", this, var, var->sharing_penalty_, penalty);
modified_ = true;
disable_var(var);
} else {
var->sharing_penalty_ = penalty;
+ if (not var->cnsts_.empty())
+ update_modified_set(var->cnsts_[0].constraint);
}
check_concurrency();
XBT_IN("(%p,%g)", this, sharing_penalty);
sharing_penalty_ = sharing_penalty;
model_->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
-
if (model_->is_update_lazy())
model_->get_action_heap().remove(this);
XBT_OUT();
return this;
}
+IoPtr Io::update_priority(double priority)
+{
+ kernel::actor::simcall([this, priority] {
+ boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->update_sharing_penalty(1. / priority);
+ });
+ return this;
+}
+
/** @brief Returns the amount of flops that remain to be done */
double Io::get_remaining() const
{