X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/faa8aeec1cac19b146adffeabe3fb4db846311b3..8ac6fbb93b5f76c67840f90d011e4845c0b6f318:/src/simix/smx_smurf.c diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index 7ed0ac1791..6b0d817b12 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -5,21 +5,34 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_smurf, simix, "Logging specific to SIMIX (SMURF)"); -/* Requests to handle at the end of this round of scheduling user processes */ -static xbt_heap_t req_todo; -/* to protect the write actions in the heap */ -static xbt_os_mutex_t sync_req_positions; +/* 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) { - req_todo = xbt_heap_new(5,NULL); - sync_req_positions = xbt_os_mutex_init(); + s_smx_req_t req; + int i, nthreads = SIMIX_context_get_parallel_threads(); + + 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) { - xbt_heap_free(req_todo); - xbt_os_mutex_destroy(sync_req_positions); + int i, nthreads = SIMIX_context_get_parallel_threads(); + + 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... */ @@ -30,18 +43,18 @@ XBT_INLINE smx_req_t SIMIX_req_mine() { 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); - if (smx_parallel_contexts) - xbt_os_mutex_acquire(sync_req_positions); - xbt_heap_push(req_todo,&issuer->request,issuer->pid); - DEBUG4("Pushed request %s (%d) of %s; now %d requests waiting", + DEBUG3("Pushed request %s (%d) of %s", SIMIX_request_name(issuer->request.call), issuer->request.call, - issuer->name,xbt_heap_size(req_todo)); - if (smx_parallel_contexts) - xbt_os_mutex_release(sync_req_positions); + issuer->name); DEBUG3("Yield process '%s' on request of type %s (%d)", issuer->name, SIMIX_request_name(issuer->request.call), issuer->request.call); @@ -53,13 +66,21 @@ void SIMIX_request_push() smx_req_t SIMIX_request_pop(void) { - smx_req_t req = xbt_heap_pop(req_todo); - if(req) - DEBUG4("Popped request %s (%d) of %s; now %d requests waiting", - SIMIX_request_name(req->issuer->request.call), - req->issuer->request.call, - req->issuer->name,xbt_heap_size(req_todo)); - return req; + int i; + smx_req_t req = NULL; + int nthreads = SIMIX_context_get_parallel_threads(); + + for(i=0; i < nthreads; i++){ + if((req = xbt_swag_extract(req_lists[i]))){ + DEBUG3("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) @@ -100,7 +121,8 @@ void SIMIX_request_pre(smx_req_t req, int value) req->comm_isend.src_buff, req->comm_isend.src_buff_size, req->comm_isend.match_fun, - req->comm_isend.data); + req->comm_isend.data, + req->comm_isend.detached); SIMIX_request_answer(req); break; @@ -268,7 +290,8 @@ void SIMIX_request_pre(smx_req_t req, int value) req->host_execute.result = SIMIX_host_execute( req->host_execute.name, req->host_execute.host, - req->host_execute.computation_amount); + req->host_execute.computation_amount, + req->host_execute.priority); SIMIX_request_answer(req); break; @@ -318,7 +341,8 @@ void SIMIX_request_pre(smx_req_t req, int value) break; case REQ_PROCESS_CREATE: - req->process_create.result = SIMIX_process_create( + SIMIX_process_create( + req->process_create.process, req->process_create.name, req->process_create.code, req->process_create.data,