typedef struct s_smx_global {
smx_context_factory_t context_factory;
xbt_dynar_t process_to_run;
+ xbt_dynar_t process_that_ran;
xbt_swag_t process_list;
xbt_swag_t process_to_destroy;
smx_process_t maestro_process;
* \brief Represents a SIMIX request.
*/
typedef struct s_smx_req {
- s_xbt_swag_hookup_t reqtable_hookup;
e_smx_req_t call;
smx_process_t issuer;
/******************************** General *************************************/
-void SIMIX_request_init(void);
-void SIMIX_request_destroy(void);
-xbt_swag_t SIMIX_request_get_reqlist(int thread_pid);
void SIMIX_request_push(void);
-smx_req_t SIMIX_request_pop(void);
void SIMIX_request_answer(smx_req_t);
void SIMIX_request_pre(smx_req_t, int);
void SIMIX_request_post(smx_action_t);
XBT_VERB("Time SSR thread %u = %lf (max %lf)", cursor, time_thread_ssr[cursor], tmax);
time_wasted_ssr += tmax - time_thread_ssr[cursor];
}
-
- xbt_dynar_reset(processes);
}
void smx_ctx_raw_new_sr(void);
XBT_DEBUG("Schedule item %u of %lu",cursor,xbt_dynar_length(processes));
smx_ctx_raw_resume(process);
}
- xbt_dynar_reset(processes);
}
#endif
#ifdef CONTEXT_THREADS
xbt_parmap_apply(parmap, (void_f_pvoid_t)smx_ctx_raw_resume, processes);
#endif
- xbt_dynar_reset(processes);
}
static smx_context_t smx_ctx_raw_self_parallel(void)
XBT_DEBUG("Schedule item %u of %lu",cursor,xbt_dynar_length(processes));
smx_ctx_sysv_resume(process->context);
}
- xbt_dynar_reset(processes);
}
void smx_ctx_sysv_resume_parallel(smx_process_t process)
#ifdef CONTEXT_THREADS
xbt_parmap_apply(parmap, (void_f_pvoid_t)smx_ctx_sysv_resume_parallel, processes);
#endif
- xbt_dynar_reset(processes);
}
smx_context_t smx_ctx_sysv_self_parallel(void)
xbt_os_sem_release(((smx_ctx_thread_t) process->context)->begin);
xbt_os_sem_acquire(((smx_ctx_thread_t) process->context)->end);
}
- xbt_dynar_reset(processes);
}
static void smx_ctx_thread_runall_parallel(xbt_dynar_t processes)
xbt_dynar_foreach(processes, index, process) {
xbt_os_sem_acquire(((smx_ctx_thread_t) process->context)->end);
}
- xbt_dynar_reset(processes);
}
static smx_context_t smx_ctx_thread_self(void)
simix_global = xbt_new0(s_smx_global_t, 1);
- simix_global->process_to_run = xbt_dynar_new(sizeof(void *), NULL);
+ simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), NULL);
+ simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_list =
xbt_swag_new(xbt_swag_offset(proc, process_hookup));
simix_global->process_to_destroy =
__xbt_running_ctx_fetch = SIMIX_process_get_running_context;
__xbt_ex_terminate = SIMIX_process_exception_terminate;
- /* Initialize request mechanism */
- SIMIX_request_init();
-
/* Initialize the SIMIX network module */
SIMIX_network_init();
/* Exit the SIMIX network module */
SIMIX_network_exit();
- /* Exit request mechanism */
- SIMIX_request_destroy();
-
xbt_heap_free(simix_timers);
/* Free the remaining data structures */
xbt_dynar_free(&simix_global->process_to_run);
+ xbt_dynar_free(&simix_global->process_that_ran);
xbt_swag_free(simix_global->process_to_destroy);
xbt_swag_free(simix_global->process_list);
simix_global->process_list = NULL;
void SIMIX_run(void)
{
double time = 0;
- smx_req_t req;
+ smx_process_t process;
xbt_swag_t set;
surf_action_t action;
smx_timer_t timer;
XBT_DEBUG("New Sub-Schedule Round; size(queue)=%lu",
xbt_dynar_length(simix_global->process_to_run));
SIMIX_context_runall(simix_global->process_to_run);
- while ((req = SIMIX_request_pop())) {
- XBT_DEBUG("Handling request %p", req);
- SIMIX_request_pre(req, 0);
+ xbt_dynar_t tmp = simix_global->process_that_ran;
+ simix_global->process_that_ran = simix_global->process_to_run;
+ simix_global->process_to_run = tmp;
+ xbt_dynar_reset(simix_global->process_to_run);
+ xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
+ if (process->request.call != REQ_NO_REQ) {
+ XBT_DEBUG("Handling request %p", &process->request);
+ SIMIX_request_pre(&process->request, 0);
+ }
}
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_smurf, simix,
"Logging specific to SIMIX (SMURF)");
-/* Tables with the requests to handle at the end of this round of scheduling
- * user processes. There is one for each thread of execution. */
-static xbt_swag_t *req_lists;
-
-void SIMIX_request_init(void)
-{
- s_smx_req_t req;
- int i, nthreads = SIMIX_context_get_nthreads();
-
- req_lists = xbt_new0(xbt_swag_t, nthreads);
- for(i=0; i < nthreads; i++)
- req_lists[i] = xbt_swag_new(xbt_swag_offset(req, reqtable_hookup));
-
-}
-
-void SIMIX_request_destroy(void)
-{
- int i, nthreads = SIMIX_context_get_nthreads();
-
- for(i=0; i < nthreads; i++)
- xbt_swag_free(req_lists[i]);
-
- xbt_free(req_lists);
-}
-
-xbt_swag_t SIMIX_request_get_reqlist(int thread_pid)
-{
- return req_lists[thread_pid];
-}
-
/* FIXME: we may want to save the initialization of issuer... */
-XBT_INLINE smx_req_t SIMIX_req_mine() {
+XBT_INLINE smx_req_t SIMIX_req_mine()
+{
smx_process_t issuer = SIMIX_process_self();
return &issuer->request;
}
void SIMIX_request_push()
{
- xbt_swag_t req_table;
smx_process_t issuer = SIMIX_process_self();
if (issuer != simix_global->maestro_process){
issuer->request.issuer = issuer;
- req_table = SIMIX_request_get_reqlist(SIMIX_context_get_thread_id());
-
- xbt_swag_insert_at_tail(&issuer->request, req_table);
-
- XBT_DEBUG("Pushed request %s (%d) of %s",
- SIMIX_request_name(issuer->request.call), issuer->request.call,
- issuer->name);
-
XBT_DEBUG("Yield process '%s' on request of type %s (%d)", issuer->name,
SIMIX_request_name(issuer->request.call), issuer->request.call);
SIMIX_process_yield();
}
}
-smx_req_t SIMIX_request_pop(void)
-{
- int i;
- smx_req_t req = NULL;
- int nthreads = SIMIX_context_get_nthreads();
-
- for(i=0; i < nthreads; i++){
- if((req = xbt_swag_extract(req_lists[i]))){
- XBT_DEBUG("Popped request %s (%d) of %s",
- SIMIX_request_name(req->issuer->request.call),
- req->issuer->request.call,
- req->issuer->name);
- return req;
- }
- }
-
- return NULL;
-}
-
void SIMIX_request_answer(smx_req_t req)
{
if (req->issuer != simix_global->maestro_process){