|ESBALLOC(9F)||Kernel Functions for Drivers||ESBALLOC(9F)|
#include <sys/stream.h> mblk_t *esballoc(uchar_t *base, size_t size, uint_t pri, frtn_t *fr_rtnp);
mblk_t *desballoc(uchar_t *base, size_t size, uint_t pri, frtn_t *fr_rtnp);
mblk_t *esballoca(uchar_t *base, size_t size, uint_t pri, frtn_t *fr_rtnp);
mblk_t *desballoca(uchar_t *base, size_t size, uint_t pri, frtn_t *fr_rtnp);
esballoca(): illumos DDI specific (illumos DDI) desballoc(): illumos DDI specific (illumos DDI) desballoca(): illumos DDI specific (illumos DDI)
The free_rtn(9S) structure includes the following members:
void (*free_func)(); /* caller's freeing routine */ caddr_t free_arg; /* argument to free_func() */
Instead of requiring a specific number of arguments, the free_arg field is defined of type caddr_t. This way, the driver can pass a pointer to a structure if more than one argument is needed. Note that the address of the free_rtn(9S) structure passed to esballoc() is used when the returned mblk/dblk pair is freed, and must remain valid until then.
If esballoc() or esballoca() was used, then free_func will be called asynchronously at some point after the message is no longer referenced. If desballoc() or desballoca() was used, then free_func will be called synchronously by the thread releasing the final reference. See freeb(9F).
The free_func routine must not sleep, and must not access any dynamically allocated data structures that could be freed before or during its execution. In addition, because messages allocated with desballoc() or desballoca() are freed in the context of the caller, free_func must not call another module's put procedure, or attempt to acquire a private module lock which might be held by another thread across a call to a STREAMS utility routine that could free a message block. Finally, free_func routines specified using desballoc() or desballoca() may run in interrupt context and thus must only use synchronization primitives that include an interrupt priority returned from ddi_intr_get_pri(9F) or ddi_intr_get_softint_pri(9F). If any of these restrictions are not followed, the possibility of lock recursion or deadlock exists.
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
Writing Device Drivers
STREAMS Programming Guide
|April 24, 2021||OmniOS|