void async_progress_disable (async_progress_t * async_progress, pami_context_t context) { pami_result_t result; async_progress_impl_t * async = (async_progress_impl_t *) async_progress; /* * Sanity check that the context lock is held by the async progress extension. */ result = PAMI_ERROR; result = PAMI_Context_trylock (context); assert (result == PAMI_EAGAIN); /* * Disable async progress for this context. */ result = PAMI_ERROR; result = async->disable_fn (context, ASYNC_PROGRESS_EVENT_ALL); assert (result == PAMI_SUCCESS); /* * Block until the context is no longer under async progress. This occurs * when the context lock is released ? */ fprintf (stdout, "(%03d) Waiting to acquire the context lock.\n", __LINE__); PAMI_Context_lock (context); fprintf (stdout, "(%03d) Acquired the context lock - async progress is now disabled.\n", __LINE__); return; };
void* thread_routine(void* input) { pami_result_t res = PAMI_ERROR; pami_context_t ctx = (pami_context_t)input; int my_key; // get the lock do { res = PAMI_Context_trylock (ctx); } while (res != PAMI_SUCCESS); // modify the common data my_key = keys; #if DBG fprintf (stderr, "%d: changed common data from %d to %d\n", pthread_self(), my_key, my_key+1); #endif my_key ++; keys = my_key; // release the lock res = PAMI_Context_unlock (ctx); if (res != PAMI_SUCCESS) { fprintf (stderr, "Error. Unable to unlock the pami context. result = %d\n", res); } pthread_exit(NULL); }
void async_progress_enable(async_progress_t * async_progress, pami_context_t context) { pami_result_t rc = PAMI_ERROR; async_progress_impl_t * async = (async_progress_impl_t *) async_progress; /* Register the async progress event handlers for this context. */ rc = PAMI_ERROR; rc = async->register_fn(context, NULL, /* progress function */ NULL, /* suspend function */ NULL, /* resume function */ NULL); /* cookie */ PAMID_ASSERT(rc==PAMI_SUCCESS,"async->register_fn"); /* Enable async progress for this context. */ rc = PAMI_ERROR; rc = async->enable_fn(context, ASYNC_PROGRESS_EVENT_ALL); PAMID_ASSERT(rc==PAMI_SUCCESS,"async->enable_fn"); /* Async progress is enabled when the async progress extension acquires the context lock. */ do { rc = PAMI_ERROR; rc = PAMI_Context_trylock (context); PAMID_ASSERT(rc!=PAMI_ERROR,"PAMI_Context_trylock"); if (rc == PAMI_SUCCESS) PAMI_Context_unlock (context); } while (rc == PAMI_SUCCESS); return; }
void async_progress_enable (async_progress_t * async_progress, pami_context_t context) { pami_result_t result; async_progress_impl_t * async = (async_progress_impl_t *) async_progress; /* * Register the async progress event handlers for this context. */ result = PAMI_ERROR; result = async->register_fn (context, NULL, /* progress function */ NULL, /* suspend function */ NULL, /* resume function */ NULL); /* cookie */ assert (result == PAMI_SUCCESS); /* * Enable async progress for this context. */ result = PAMI_ERROR; result = async->enable_fn (context, ASYNC_PROGRESS_EVENT_ALL); assert (result == PAMI_SUCCESS); /* * Async progress is enabled when the async progress extension acquires the * context lock. */ fprintf (stdout, "(%03d) Waiting for the async progress extension to acquire the context lock.\n", __LINE__); do { result = PAMI_ERROR; result = PAMI_Context_trylock (context); assert (result != PAMI_ERROR); if (result == PAMI_SUCCESS) PAMI_Context_unlock (context); } while (result == PAMI_SUCCESS); fprintf (stdout, "(%03d) Async progress enabled for the context.\n", __LINE__); return; }
void async_progress_disable(async_progress_t * async_progress, pami_context_t context) { #if 0 pami_result_t rc = PAMI_ERROR; async_progress_impl_t * async = (async_progress_impl_t *) async_progress; /* Sanity check that the context lock is held by the async progress extension. */ rc = PAMI_ERROR; rc = PAMI_Context_trylock(context); PAMID_ASSERT(rc==PAMI_EAGAIN,"PAMI_Context_trylock"); /* Disable async progress for this context. */ rc = PAMI_ERROR; rc = async->disable_fn(context, ASYNC_PROGRESS_EVENT_ALL); PAMID_ASSERT(rc==PAMI_SUCCESS,"async->disable_fn"); /* Block until the context is no longer under async progress. This occurs when the context lock is released? */ rc = PAMI_Context_lock(context); PAMID_ASSERT(rc==PAMI_SUCCESS,"PAMI_Context_trylock"); #endif return; }