Copyright (C) 2001 Chad David <firstname.lastname@example.org>. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice(s), this list of conditions and the following disclaimer as the first lines of this file unmodified other than the possible addition of one or more copyright notices. 2. Redistributions in binary for...
NAMEpbuf getpbuf trypbuf relpbuf - functions for managing physical buffers
SYNOPSISIn sys/param.h In sys/systm.h In sys/bio.h In sys/buf.h Ft struct buf * Fn getpbuf int *pfreecnt Ft struct buf * Fn trypbuf int *pfreecnt Ft void Fn relpbuf struct buf *bp int *pfreecnt
DESCRIPTIONThese functions are used to allocate and release physical buffers.
The physical buffers are allocated at system startup and are maintained in a separate pool from the main system buffers. They are intended for use by subsystems that cannot or should not be reliant on the main pool of buffers (for example the swap pager). The system allocates between 16 and 256 physical buffers depending on the amount of memory in the system.
Each subsystem that allocates buffers via these calls is expected to manage its own percentage free counter. If the value is initialized to -1 the number of buffers available to the subsystem is limited only by the number of physical buffers available. The number of buffers is stored in nswbuf which is defined in In sys/buf.h and initialized in Fn cpu_startup . A recommended initialization value is 1/2 nswbuf
The Fn getpbuf function returns the first available buffer to the user. If there are no buffers available, Fn getpbuf will sleep waiting for one to become available. If Fa pfreecnt is zero, Fn getpbuf will sleep until it increases. Fa pfreecnt is decremented prior to returning.
The Fn trypbuf function returns the first available buffer. If there are no buffers available, NULL is returned. As well, if Fa pfreecnt is zero, NULL is returned. Fa pfreecnt is decremented prior to returning a valid buffer. If NULL is returned, Fa pfreecnt is not modified.
The Fn relpbuf function releases the buffer back to the free list. If the buffers b_rcred or b_wcred structures are not NULL they are freed. See crfree(9).
Fa pfreecnt is incremented prior to returning.