include examples/c/async-waitany/async-waitany.c
include examples/c/async-waitany/async-waitany.tesh
include examples/c/async-waitany/async-waitany_d.xml
+include examples/c/io-disk-raw/io-disk-raw.c
+include examples/c/io-disk-raw/io-disk-raw.tesh
include examples/deprecated/java/app/bittorrent/Common.java
include examples/deprecated/java/app/bittorrent/Connection.java
include examples/deprecated/java/app/bittorrent/Main.java
include teshsuite/msg/io-file-remote/io-file-remote_d.xml
include teshsuite/msg/io-file/io-file.c
include teshsuite/msg/io-file/io-file.tesh
-include teshsuite/msg/io-raw-storage/io-raw-storage.c
-include teshsuite/msg/io-raw-storage/io-raw-storage.tesh
include teshsuite/msg/platform-properties/platform-properties.c
include teshsuite/msg/platform-properties/platform-properties.tesh
include teshsuite/msg/platform-properties/platform-properties_d.xml
-foreach(x actor-create app-pingpong async-waitany)
+foreach(x actor-create app-pingpong async-waitany io-disk-raw)
add_executable (${x}-c EXCLUDE_FROM_ALL ${x}/${x}.c)
target_link_libraries(${x}-c simgrid)
set_target_properties(${x}-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml
PARENT_SCOPE)
-foreach(x actor-create app-pingpong async-waitany)
+foreach(x actor-create app-pingpong async-waitany io-disk-raw)
ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
--setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x}
--cd ${CMAKE_HOME_DIRECTORY}/examples/c/${x}
--- /dev/null
+/* Copyright (c) 2006-2020. 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/actor.h"
+#include "simgrid/disk.h"
+#include "simgrid/engine.h"
+#include "simgrid/forward.h"
+#include "simgrid/host.h"
+#include "xbt/dict.h"
+#include "xbt/log.h"
+#include "xbt/sysdep.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(disk, "Messages specific for this simulation");
+
+static void host(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ const char* host_name = sg_host_get_name(sg_host_self());
+
+ /* - Display information on the disks mounted by the current host */
+ XBT_INFO("*** Storage info on %s ***", host_name);
+
+ /* - Retrieve all disks from current host */
+ unsigned int disk_count;
+ sg_disk_t* disk_list;
+ sg_host_disks(sg_host_self(), &disk_count, &disk_list);
+
+ for (unsigned int i = 0; i < disk_count; i++)
+ XBT_INFO("Disk name: %s (read: %.0f B/s -- write: %.0f B/s ", sg_disk_name(disk_list[i]),
+ sg_disk_read_bandwidth(disk_list[i]), sg_disk_write_bandwidth(disk_list[i]));
+
+ /* - Write 400,000 bytes on Disk1 */
+ sg_disk_t disk = disk_list[0];
+ sg_size_t write = sg_disk_write(disk, 400000);
+ XBT_INFO("Wrote %llu bytes on '%s'", write, sg_disk_name(disk));
+
+ /* - Now read 200,000 bytes */
+ sg_size_t read = sg_disk_read(disk, 200000);
+ XBT_INFO("Read %llu bytes on '%s'", read, sg_disk_name(disk));
+
+ /* - Attach some user data to disk1 */
+ XBT_INFO("*** Get/set data for storage element: Disk1 ***");
+
+ char* data = (char*)sg_disk_data(disk);
+
+ XBT_INFO("Get storage data: '%s'", data ? data : "No user data");
+
+ sg_disk_data_set(disk, xbt_strdup("Some user data"));
+ data = (char*)sg_disk_data(disk);
+ XBT_INFO("Set and get data: '%s'", data);
+ free(data);
+ free(disk_list);
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid_init(&argc, argv);
+ simgrid_load_platform(argv[1]);
+
+ simgrid_register_function("host", host);
+
+ size_t host_count;
+ sg_host_t* hosts;
+ simgrid_get_all_hosts(&host_count, &hosts);
+
+ for (long i = 0; i < host_count; i++) {
+ XBT_INFO("*** %s properties ****", sg_host_get_name(hosts[i]));
+ xbt_dict_t props = sg_host_get_properties(hosts[i]);
+ xbt_dict_cursor_t cursor = NULL;
+ char* key;
+ void* data;
+ xbt_dict_foreach (props, cursor, key, data)
+ XBT_INFO(" %s -> %s", key, (char*)data);
+ xbt_dict_free(&props);
+ }
+
+ free(hosts);
+
+ sg_actor_t actor = sg_actor_init("", sg_host_by_name("bob"));
+ sg_actor_start(actor, host, 0, NULL);
+
+ simgrid_run();
+
+ XBT_INFO("Simulated time %g", simgrid_get_clock());
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir}/io-disk-raw-c ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (0:maestro@) *** alice properties ****
+> [ 0.000000] (0:maestro@) ram -> 100B
+> [ 0.000000] (0:maestro@) *** bob properties ****
+> [ 0.000000] (0:maestro@) ram -> 100B
+> [ 0.000000] (0:maestro@) *** carl properties ****
+> [ 0.000000] (0:maestro@) remote_disk -> /scratch:Disk1:bob
+> [ 0.000000] (1:@bob) *** Storage info on bob ***
+> [ 0.000000] (1:@bob) Disk name: Disk1 (read: 100000000 B/s -- write: 40000000 B/s
+> [ 0.000000] (1:@bob) Disk name: Disk2 (read: 200000000 B/s -- write: 80000000 B/s
+> [ 0.010000] (1:@bob) Wrote 400000 bytes on 'Disk1'
+> [ 0.012000] (1:@bob) Read 200000 bytes on 'Disk1'
+> [ 0.012000] (1:@bob) *** Get/set data for storage element: Disk1 ***
+> [ 0.012000] (1:@bob) Get storage data: 'No user data'
+> [ 0.012000] (1:@bob) Set and get data: 'Some user data'
+> [ 0.012000] (0:maestro@) Simulated time 0.012
get_sender host_on_off host_on_off_recv
process-daemon process-kill process-join process-lifetime process-migration process-suspend process-yield
energy-consumption energy-ptask energy-pstate platform-properties
- io-file io-raw-storage io-file-remote
+ io-file io-file-remote
task-priority
plugin-hostload
trace_integration)
task_destroy_cancel task_listen_from task_progress
process-daemon process-kill process-join process-lifetime process-migration process-suspend process-yield
energy-consumption energy-ptask
- io-file io-raw-storage io-file-remote
+ io-file io-file-remote
platform-properties
task-priority
plugin-hostload
+++ /dev/null
-/* Copyright (c) 2006-2020. 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/msg.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
-
-static int host(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- const char* host_name = MSG_host_get_name(MSG_host_self());
-
- /* - Display information on the disks mounted by the current host */
- XBT_INFO("*** Storage info on %s ***", host_name);
-
- xbt_dict_cursor_t cursor = NULL;
- char* mount_name;
- char* storage_name;
-
- /* - Retrieve all mount points of current host */
- xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
-
- /* - For each disk mounted on host, display disk name and mount point */
- xbt_dict_foreach (storage_list, cursor, mount_name, storage_name)
- XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
-
- xbt_dict_free(&storage_list);
-
- /* - Write 200,000 bytes on Disk4 */
- msg_storage_t storage = MSG_storage_get_by_name("Disk4");
- sg_size_t write = MSG_storage_write(storage, 200000); // Write 200,000 bytes
- XBT_INFO("Wrote %llu bytes on 'Disk4'", write);
-
- /* - Now read 200,000 bytes */
- sg_size_t read = MSG_storage_read(storage, 200000);
- XBT_INFO("Read %llu bytes on 'Disk4'", read);
-
- /* - Attach some user data to disk1 */
- XBT_INFO("*** Get/set data for storage element: Disk4 ***");
-
- char* data = MSG_storage_get_data(storage);
-
- XBT_INFO("Get storage data: '%s'", data);
-
- MSG_storage_set_data(storage, xbt_strdup("Some user data"));
- data = MSG_storage_get_data(storage);
- XBT_INFO("Set and get data: '%s'", data);
- xbt_free(data);
-
- return 1;
-}
-
-int main(int argc, char* argv[])
-{
- MSG_init(&argc, argv);
-
- MSG_create_environment(argv[1]);
- MSG_function_register("host", host);
- xbt_dynar_t hosts = MSG_hosts_as_dynar();
- MSG_process_create(NULL, host, NULL, xbt_dynar_get_as(hosts, 3, msg_host_t));
- xbt_dynar_free(&hosts);
-
- msg_error_t res = MSG_main();
- XBT_INFO("Simulated time: %g", MSG_get_clock());
-
- return res != MSG_OK;
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-$ ${bindir}/io-raw-storage ${platfdir}/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:@denise) *** Storage info on denise ***
-> [ 0.000000] (1:@denise) Storage name: Disk2, mount name: /tmp
-> [ 0.000000] (1:@denise) Storage name: Disk4, mount name: /home
-> [ 0.003333] (1:@denise) Wrote 200000 bytes on 'Disk4'
-> [ 0.004333] (1:@denise) Read 200000 bytes on 'Disk4'
-> [ 0.004333] (1:@denise) *** Get/set data for storage element: Disk4 ***
-> [ 0.004333] (1:@denise) Get storage data: '(null)'
-> [ 0.004333] (1:@denise) Set and get data: 'Some user data'
-> [ 0.004333] (0:maestro@) Simulated time: 0.00433333