table of contents
|EVENTHANDLER(9)||Kernel Developer's Manual||EVENTHANDLER(9)|
kernel event handling functions
eventhandler_list *list, const char *name,
void *func, void *arg,
eventhandler_list *list, eventhandler_tag
struct eventhandler_list *
EVENTHANDLER mechanism provides a way
for kernel subsystems to register interest in kernel events and have their
callback functions invoked when these events occur.
The normal way to use this subsystem is via the macro interface. The macros that can be used for working with event handlers and callback function lists are:
- This macro declares an event handler named by argument name with callback functions of type type.
- This macro registers a callback function func with
event handler name. When invoked, function
func will be invoked with argument
arg as its first parameter along with any additional
parameters passed in via macro
EVENTHANDLER_INVOKE() (see below). Callback functions are invoked in order of priority. The relative priority of each callback among other callbacks associated with an event is given by argument priority, which is an integer ranging from
EVENTHANDLER_PRI_FIRST(highest priority), to
EVENTHANDLER_PRI_LAST(lowest priority). The symbol
EVENTHANDLER_PRI_ANYmay be used if the handler does not have a specific priority associated with it. If registration is successful,
EVENTHANDLER_REGISTER() returns a cookie of type eventhandler_tag.
- This macro removes a previously registered callback associated with tag tag from the event handler named by argument name.
- This macro is used to invoke all the callbacks associated with event handler name. This macro is a variadic one. Additional arguments to the macro after the name parameter are passed as the second and subsequent arguments to each registered callback function.
The macros are implemented using the following functions:
eventhandler_register() function is used to register a callback with a given event. The arguments expected by this function are:
- A pointer to an existing event handler list, or
NULL. If list is
NULL, the event handler list corresponding to argument name is used.
- The name of the event handler list.
- A pointer to a callback function. Argument arg is passed to the callback function func as its first argument when it is invoked.
- The relative priority of this callback among all the callbacks
registered for this event. Valid values are those in the range
eventhandler_register() function returns a tag that can later be used with
eventhandler_deregister() to remove the particular callback function.
eventhandler_deregister() function removes the callback associated with tag tag from the event handler list pointed to by list. This function is safe to call from inside an event handler callback.
eventhandler_find_list() function returns a pointer to event handler list structure corresponding to event name.
eventhandler_prune_list() function removes all deregistered callbacks from the event list list.
Kernel Event Handlers¶
The following event handlers are present in the kernel:
- Callbacks invoked when the system is being sent to sleep.
- Callbacks invoked when the system is being woken up.
- Callbacks invoked at start of application core dump.
- Callbacks invoked during progress of application core dump.
- Callbacks invoked at finish of application core dump.
- Callbacks invoked on error of application core dump.
- Callbacks invoked when a BPF listener attaches to/detaches from network interface.
- Callback invoked when cpu frequency levels have changed.
- Callback invoked after cpu frequency has changed.
- Callback invoked before cpu frequency has changed.
- Callback invoked to poll for dcons changes.
- Callbacks invoked when a new entry is created under /dev.
- Callback invoked when an interfance has been added to an interface group.
- Callback invoked when an change has been made to an interface group.
- Callback invoked when an interfance has been removed from an interface group.
- Callbacks invoked when an address is set up on a network interface.
- Callbacks invoked when an interface is cloned.
- Callback invoked when an if link layer address event has happened.
- Callbacks invoked when a new network interface appears.
- Callbacks invoked when a network interface is taken down.
- Callback invoked when an interfance link event has happened.
- Callbacks invoked after a linker file has been loaded.
- Callbacks invoked after a linker file has been successfully unloaded.
- Callbacks invoked before a linker file is about to be unloaded. These callbacks may be used to return an error and prevent the unload from proceeding.
- Callback invoked when an link layer event has happened.
- Callback invoked when the number of mbuf clusters has changed.
- Callback invoked when the number of mbufs has changed.
- Callback invoked when the maximum number of sockets has changed.
- Callback invoked when root has been mounted.
- Callbacks invoked when the power profile of the system changes.
- Callback invoked when the system has resumed.
- Callback invoked just before the system is suspended.
- Callback invoked when a process is created.
- Callback invoked when a process is destroyed.
- Callbacks invoked when a process performs an
- Callbacks invoked when a process exits.
- Callback invoked when a process memory is destroyed. This is never called.
- Callbacks invoked when a process forks a child.
- Callback invoked when a process is initalized.
- Callback invoked when a new random module has been loaded.
- Callback invoked when a new frame buffer is registered.
- Callback invoked when a route gets redirected to a new location.
- Callbacks invoked at shutdown time, before file systems are synchronized.
- Callbacks invoked at shutdown time, after all file systems are synchronized.
- Callbacks invoked just before halting the system.
- Callback invoked for TCP Offload to start listening for new connections.
- Callback invoked ror TCP Offload to stop listening for new connections.
- Callback invoked when a thread object is created.
- Callback invoked when a thread object is destroyed.
- Callback invoked when a thread object is initalized.
- Callback invoked when a thread object is deinitalized.
- Callback invoked when a USB device is configured
- Callback invoked when a frame buffer is deregistered.
- Callback invoked when a file system is mounted.
- Callback invoked when a file system is unmounted.
- Callback invoked when the vlan configuration has changed.
- Callback invoked when a vlan is destroyed.
- Callbacks invoked when virtual memory is low.
- Callbacks invoked when the system watchdog timer is reinitialized.
eventhandler_register() return a cookie of
type eventhandler_tag, which may be used in a
subsequent call to
returns a pointer to an event handler list corresponding to parameter
NULL if no such list
EVENTHANDLER facility first appeared
in FreeBSD 4.0.
This manual page was written by Joseph Koshy <jkoshy@FreeBSD.org>.
|April 19, 2014||Debian|