DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

sdi_get(D3sdi)


sdi_get -- allocate a structure from the pool of structures

Synopsis

   #include <sys/sdi.h>

struct jpool * sdi_get(struct head *headp, int flag);

Description

sdi_get allocates a structure from the available pool of headp. If the pool is empty, an attempt is made to allocate more kernel memory to satisfy the current request. If additional memory cannot be allocated and flag was enabled, the routine will sleep.

Arguments


headp
pointer to the head structure of the pool from which the memory piece was allocated

flag
the flag which is used to decide whether sdi_get can sleep if no structures are currently available

Return values

Pointer to a jpool structure.

Usage

sdi_get is typically used in a local getblk/getjob routine. Rather than having a local pool of job or command structures, SDI drivers should use one of the two existing shared pools. If the size of structures in these pools are too small, a new pool can be created and used by the SDI driver.

There are two pools initialized and used by existing SDI drivers. They are struct head sm_poolhead (28 bytes per structure) and struct head lg_poolhead (76 bytes per structure). Currently, most of the HBA drivers use the small structures for command blocks, and the target drivers use the large structures for job structures.

There are two rules for use of the structures:

If you need to bcopy another structure into the structure allocated from sdi_get, save the third word and restore it after the copy.

In SVR4.2 MP, the sdi_get and sdi_free(D3sdi) routines do nothing more than call kmem_zalloc(D3) and kmem_free(D3). The headp parameter is maintained simply to keep a record of the allocation size.

Context and synchronization

If flag is set to KM_NOSLEEP, non-blockable, initialization, or interrupt context.

If flag is set to KM_SLEEP, user context.

Applicable hardware

x86/Pentium compatible architectures

Version applicability

sdi: 1, 2, 3, 4 HBA and target drivers.

References

kmem_free(D3), kmem_zalloc(D3), sdi_free(D3sdi)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005