X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/34c6518ab6cdb0b402cca01ac045561cba9bd009..725184f3bce66a3eff87cc3a01e5d96477a5d28a:/src/xbt/xbt_context.c diff --git a/src/xbt/xbt_context.c b/src/xbt/xbt_context.c index 03ff6d12c8..d969580938 100644 --- a/src/xbt/xbt_context.c +++ b/src/xbt/xbt_context.c @@ -11,6 +11,9 @@ #include "xbt/swag.h" #include "xbt_context_private.h" +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_context, xbt, + "Context switching mecanism"); + /* the context associated with the current process */ xbt_context_t current_context = NULL; @@ -24,7 +27,7 @@ xbt_swag_t context_to_destroy = NULL; /* this list contains the contexts in use */ xbt_swag_t context_living = NULL; -/* the context factory used to create the appropriate context +/* the context factory used to create the appropriate context * each context implementation define its own context factory * a context factory is responsable of the creation of the context * associated with the maestro and of all the context based on @@ -95,7 +98,7 @@ void xbt_context_mod_exit(void) /* remove the context of the scheduler from the list of the contexts in use */ xbt_swag_remove(maestro_context, context_living); - /* + /* * kill all the contexts in use : * the killed contexts are added in the list of the contexts to destroy */ @@ -118,12 +121,12 @@ void xbt_context_mod_exit(void) /*******************************/ /* Object creation/destruction */ /*******************************/ -/** +/** * \param code a main function * \param startup_func a function to call when running the context for * the first time and just before the main function \a code * \param startup_arg the argument passed to the previous function (\a startup_func) - * \param cleanup_func a function to call when running the context, just after + * \param cleanup_func a function to call when running the context, just after the termination of the main function \a code * \param cleanup_arg the argument passed to the previous function (\a cleanup_func) * \param argc first argument of function \a code @@ -151,22 +154,22 @@ xbt_context_new(const char *name, } /* Scenario for the end of a context: - * + * * CASE 1: death after end of function * __context_wrapper, called by os thread, calls xbt_context_stop after user code stops * xbt_context_stop calls user cleanup_func if any (in context settings), * add current to trashbin * yields back to maestro (destroy os thread on need) - * From time to time, maestro calls xbt_context_empty_trash, + * From time to time, maestro calls xbt_context_empty_trash, * which maps xbt_context_free on the content - * xbt_context_free frees some more memory, + * xbt_context_free frees some more memory, * joins os thread - * + * * CASE 2: brutal death * xbt_context_kill (from any context) * set context->wannadie to 1 * yields to the context - * the context is awaken in the middle of __yield. + * the context is awaken in the middle of __yield. * At the end of it, it checks that wannadie == 1, and call xbt_context_stop * (same than first case afterward) */ @@ -184,10 +187,10 @@ void xbt_context_kill(xbt_context_t context) (*(context->kill)) (context); } -/** +/** * \param context the context to start - * - * Calling this function prepares \a context to be run. It will + * + * Calling this function prepares \a context to be run. It will however run effectively only when calling #xbt_context_schedule */ void xbt_context_start(xbt_context_t context) @@ -195,11 +198,11 @@ void xbt_context_start(xbt_context_t context) (*(context->start)) (context); } -/** +/** * Calling this function makes the current context yield. The context * that scheduled it returns from xbt_context_schedule as if nothing * had happened. - * + * * Only the processes can call this function, giving back the control * to the maestro */ @@ -208,13 +211,13 @@ void xbt_context_yield(void) (*(current_context->yield)) (); } -/** +/** * \param context the winner * - * Calling this function blocks the current context and schedule \a context. + * Calling this function blocks the current context and schedule \a context. * When \a context will call xbt_context_yield, it will return * to this function as if nothing had happened. - * + * * Only the maestro can call this function to run a given process. */ void xbt_context_schedule(xbt_context_t context)