examples/msg/energy-onoff/energy-onoff
examples/msg/energy-pstate/energy-pstate
examples/msg/energy-vm/energy-vm
-examples/msg/io-file/io-file
examples/msg/io-file-unlink/io-file-unlink
examples/msg/io-remote/io-remote
examples/msg/io-storage/io-storage
examples/s4u/energy-ptask/s4u-energy-ptask
examples/s4u/energy-pstate/s4u-energy-pstate
examples/s4u/energy-vm/s4u-energy-vm
-examples/s4u/io/s4u-io
+examples/s4u/io-file-system/s4u-io-file-system
examples/s4u/io-file-remote/s4u-io-file-remote
examples/s4u/io-storage-raw/s4u-io-storage-raw
examples/s4u/mutex/s4u-mutex
teshsuite/msg/host_on_off_processes/host_on_off_processes
teshsuite/msg/host_on_off_recv/host_on_off_recv
teshsuite/msg/host_on_off_wait/host_on_off_wait
+teshsuite/msg/io-file/io-file
teshsuite/msg/io-file-remote/io-file-remote
teshsuite/msg/io-raw-storage/io-raw-storage
teshsuite/msg/listen_async/listen_async
foreach(x app-masterworker app-pingpong app-token-ring
cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
dht-pastry energy-consumption energy-onoff energy-vm platform-failures
- io-file task-priority
+ task-priority
plugin-hostload
process-create process-join
synchro-semaphore trace-categories
foreach(x app-chainsend app-masterworker app-pingpong app-token-ring
cloud-capping cloud-masterworker cloud-migration cloud-simple
- cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file task-priority
+ cloud-two-tasks dht-pastry dht-kademlia platform-failures task-priority
energy-consumption energy-onoff energy-vm
plugin-hostload
process-create process-join
- @ref msg_ex_tracing_user_variables
- @ref msg_ex_models
- @ref msg_ex_ns3
- - @ref msg_ex_io
- @ref msg_ex_apps
- @ref msg_ex_misc
TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet.
-@subsection msg_ex_io Simulating disks and files
-
-The examples of this section demonstrate how to interact with the
-simulated storages.
-
- - <b>File Management</b>. @ref examples/msg/io-file/io-file.c \n
- This example illustrates the use of operations on file
- (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write,
- or @ref MSG_file_close).
-
@section msg_ex_misc Miscellaneous
- <b>Task priorities</b>.
@example examples/msg/network-ns3/network-ns3.c
-@example examples/msg/io-file/io-file.c
-
@example examples/msg/task-priority/task-priority.c
*/
app-masterworker app-pingpong app-token-ring
async-wait async-waitany async-waitall
energy-link energy-pstate energy-ptask energy-vm
- io io-file-remote io-storage-raw
+ io-file-system io-file-remote io-storage-raw
platform-properties plugin-hostload mutex)
add_executable (s4u-${example} ${example}/s4u-${example}.cpp)
target_link_libraries(s4u-${example} simgrid)
dht-chord
energy-link energy-pstate energy-ptask energy-vm
platform-properties plugin-hostload mutex
- io io-file-remote io-storage-raw)
+ io-file-system io-file-remote io-storage-raw)
ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost"
--setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
--setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
The examples of this section demonstrate how to interact with the
simulated storages.
+ - <b>File Management</b>. @ref examples/s4u/io-file-system/s4u-io-file-system.cpp \n
+ This example illustrates the use of operations on files
+ (read, write, seek, tell, unlink, ...).
+
- <b>Access to raw storage devices </b>.
@ref examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
This example illustrates how to simply read and write data on a
@example examples/s4u/async-waitall/s4u-async-waitall.cpp
@example examples/s4u/async-waitany/s4u-async-waitany.cpp
@example examples/s4u/energy-pstate/s4u-energy-pstate.cpp
+@example examples/s4u/io-file-system/s4u-io-file-system.cpp
@example examples/s4u/io-file-remote/s4u-io-file-remote.cpp
@example examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
@example examples/s4u/mutex/s4u-mutex.cpp
}
}
- void operator()() {
+ void operator()()
+ {
std::unordered_map<std::string, simgrid::s4u::Storage*> const& mounts =
simgrid::s4u::Host::current()->getMountedStorages();
std::string filename = "/home/tmp/data.txt";
simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
- sg_size_t write = file->write(200000); // Write 200,000 bytes
+ sg_size_t write = file->write(200000); // Write 200,000 bytes
XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename.c_str());
// check that sizes have changed
XBT_INFO("Read %llu bytes on %s", read, filename.c_str());
// Now write 100,000 bytes in tmp/data.txt
- write = file->write(100000); // Write 100,000 bytes
+ write = file->write(100000); // Write 100,000 bytes
XBT_INFO("Write %llu bytes on %s", write, filename.c_str());
simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4");
}
};
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
simgrid::s4u::Engine e(&argc, argv);
sg_storage_file_system_init();
#! ./tesh
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-io ${platfdir}/storage/storage.xml
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-io-file-system ${platfdir}/storage/storage.xml
> [denise:host:(1) 0.000000] [s4u_test/INFO] Storage info on denise:
> [denise:host:(1) 0.000000] [s4u_test/INFO] Disk2 (c:) Used: 2391537133; Free: 534479374867; Total: 536870912000.
> [denise:host:(1) 0.000000] [s4u_test/INFO] Disk4 (/home) Used: 13221994; Free: 536857690006; Total: 536870912000.
cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes
process-daemon process-kill process-lifetime process-migration process-suspend process-yield
energy-ptask energy-pstate platform-properties
- io-raw-storage io-file-remote
+ io-file io-raw-storage io-file-remote
trace_integration)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
task_destroy_cancel task_listen_from task_progress
process-daemon process-kill process-lifetime process-migration process-suspend process-yield
energy-ptask
- io-raw-storage io-file-remote
+ io-file io-raw-storage io-file-remote
platform-properties
trace_integration)
ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost"
XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
-static int host(int argc, char *argv[])
+static int host(int argc, char* argv[])
{
msg_file_t file = NULL;
sg_size_t read;
msg_storage_t st;
const char* st_name;
- switch(MSG_process_self_PID()){
- case 1:
- file = MSG_file_open("c:\\Windows\\setupact.log", NULL);
- st_name = "Disk2";
- break;
- case 2:
- file = MSG_file_open("/home/doc/simgrid/examples/platforms/nancy.xml", NULL);
- st_name = "Disk1";
- break;
- case 3:
- file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k_cabinets.xml", NULL);
- st_name = "Disk3";
- break;
- case 4:
- file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k.xml", NULL);
- MSG_file_dump(file);
- st_name = "Disk4";
- break;
- default:
- xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self()));
+ switch (MSG_process_self_PID()) {
+ case 1:
+ file = MSG_file_open("c:\\Windows\\setupact.log", NULL);
+ st_name = "Disk2";
+ break;
+ case 2:
+ file = MSG_file_open("/home/doc/simgrid/examples/platforms/nancy.xml", NULL);
+ st_name = "Disk1";
+ break;
+ case 3:
+ file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k_cabinets.xml", NULL);
+ st_name = "Disk3";
+ break;
+ case 4:
+ file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k.xml", NULL);
+ MSG_file_dump(file);
+ st_name = "Disk4";
+ break;
+ default:
+ xbt_die("FILENAME NOT DEFINED %s", MSG_process_get_name(MSG_process_self()));
}
const char* filename = MSG_file_get_name(file);
- XBT_INFO("\tOpen file '%s'",filename);
+ XBT_INFO("\tOpen file '%s'", filename);
st = MSG_storage_get_by_name(st_name);
- XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
- filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+ XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
+ MSG_storage_get_size(st));
/* Try to read for 10MB */
read = MSG_file_read(file, 10000000);
- XBT_INFO("\tHave read %llu from '%s'",read,filename);
+ XBT_INFO("\tHave read %llu from '%s'", read, filename);
/* Write 100KB in file from the current position, i.e, end of file or 10MB */
write = MSG_file_write(file, 100000);
- XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename, MSG_file_get_size(file));
+ XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write, filename, MSG_file_get_size(file));
-
- XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
- filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+ XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
+ MSG_storage_get_size(st));
/* rewind to the beginning of the file */
XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
/* Try to read 110KB */
read = MSG_file_read(file, 110000);
- XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename, MSG_file_get_size(file));
+ XBT_INFO("\tHave read %llu from '%s' (of size %llu)", read, filename, MSG_file_get_size(file));
/* rewind once again to the beginning of the file */
XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
/* Write 110KB in file from the current position, i.e, end of file or 10MB */
write = MSG_file_write(file, 110000);
- XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename, MSG_file_get_size(file));
+ XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write, filename, MSG_file_get_size(file));
- XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
- filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+ XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
+ MSG_storage_get_size(st));
- if (MSG_process_self_PID() == 1){
+ if (MSG_process_self_PID() == 1) {
XBT_INFO("\tUnlink file '%s'", MSG_file_get_name(file));
MSG_file_unlink(file);
} else {
return 0;
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
MSG_init(&argc, argv);
MSG_storage_file_system_init();
MSG_create_environment(argv[1]);
- xbt_dynar_t hosts = MSG_hosts_as_dynar();
+ xbt_dynar_t hosts = MSG_hosts_as_dynar();
MSG_function_register("host", host);
unsigned long nb_hosts = xbt_dynar_length(hosts);
- XBT_INFO("Number of host '%lu'",nb_hosts);
- for(int i = 0 ; i < nb_hosts; i++){
- MSG_process_create("host", host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t));
+ XBT_INFO("Number of host '%lu'", nb_hosts);
+ for (int i = 0; i < nb_hosts; i++) {
+ MSG_process_create("host", host, NULL, xbt_dynar_get_as(hosts, i, msg_host_t));
}
xbt_dynar_free(&hosts);