- (*factory)->self = smx_ctx_raw_self_parallel;
- (*factory)->get_thread_id = smx_ctx_raw_get_thread_id;
- (*factory)->runall = smx_ctx_raw_runall;
+
+ if (SIMIX_context_is_parallel()) {
+ if (SIMIX_context_get_parallel_threshold() > 1) {
+ /* choose dynamically */
+ (*factory)->runall = smx_ctx_raw_runall;
+ }
+ else {
+ /* always parallel */
+ (*factory)->self = smx_ctx_raw_self_parallel;
+ (*factory)->get_thread_id = smx_ctx_raw_get_thread_id;
+ (*factory)->runall = smx_ctx_raw_runall_parallel;
+ }
+ }
+ else {
+ /* always serial */
+ (*factory)->self = smx_ctx_base_self;
+ (*factory)->get_thread_id = smx_ctx_base_get_thread_id;
+ (*factory)->runall = smx_ctx_raw_runall_serial;
+ }