NAME
mthr_set_shutdownhandler - install a new shutdown handler

SYNOPSIS
#include <mthread.h>

shutdown_handler_t mthr_set_shutdownhandler(shutdown_handler_t new_handler);

DESCRIPTION
When the last userlevel thread terminates or the function mthr_halt(3) is called manually, a central function, the shutdown handler will be called. This offers the possibility to do some cleanup or statistics before the application will terminate without having to think about which userlevel thread will be the last and will have to do this work.

The default shutdown handler mthr_default_shutdown() does nothing but terminate the application.

The handler mthr_profile_shutdown() prints some useful profiling information like the number of scheduling decisions, the number of thread migrations etc. for each of the used processors. This information can give hints how to improve an application's performance by tuning the package's configuration parameters.

To install an own shutdown handler, the user must offer a function of the following type:

   void (*shutdown_handler_t)(int exitvalue)

mthr_set_shutdownhandler will install new_handler as the new shutdown handler and return a reference to the old one. If new_handler is a null pointer, only the old handler will be returned, but no new handler will be installed.

SEE ALSO
mthreads(3), mthr_halt(3), mthr_config(3), mthr_configv