+
+static void surf_share_resources(surf_model_t model) {
+
+ if (strcmp(model->name,"network NS3")) {
+ XBT_DEBUG("Running for Resource [%s]", model->name);
+ double next_action_end = model->model_private->share_resources(NOW);
+ XBT_DEBUG("Resource [%s] : next action end = %f",
+ model->name, next_action_end);
+ int i = __sync_fetch_and_add(&surf_min_index, 1);
+ surf_mins[i] = next_action_end;
+ }
+}
+
+/**
+ * \brief Returns the number of parallel threads used to update the models.
+ * \return the number of threads (1 means no parallelism)
+ */
+int surf_get_nthreads(void) {
+ return surf_nthreads;
+}
+
+/**
+ * \brief Sets the number of parallel threads used to update the models.
+ *
+ * A value of 1 means no parallelism.
+ *
+ * \param nb_threads the number of threads to use
+ */
+void surf_set_nthreads(int nthreads) {
+
+ xbt_assert(nthreads > 0, "Invalid number of parallel threads: %d", nthreads);
+
+ if (nthreads > 1) {
+#ifndef CONTEXT_THREADS
+ THROWF(arg_error, 0, "Cannot activate parallel threads in Surf: your architecture does not support threads");
+#endif
+ }
+
+ surf_nthreads = nthreads;
+}