Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../data-stud/../../usr/man/man9f/kmem_alloc.9f
Real path: /usr/share/man/man9f/kmem_alloc.9f
Zurück
'\" te .\" Copyright (c) 1989, AT&T. All rights reserved. .\" Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. .TH kmem_alloc 9F "24 Dec 2013" "Oracle Solaris 11.4" "Kernel Functions" .SH NAME kmem_alloc, kmem_zalloc, kmem_free \- allocate kernel memory .SH SYNOPSIS .LP .nf #include <sys/types.h> #include <sys/kmem.h> \fBvoid *\fR\fBkmem_alloc\fR(\fBsize_t\fR \fIsize\fR, \fBint\fR \fIflag\fR); .fi .LP .nf \fBvoid *\fR\fBkmem_zalloc\fR(\fBsize_t\fR \fIsize\fR, \fBint\fR \fIflag\fR); .fi .LP .nf \fBvoid\fR \fBkmem_free\fR(\fBvoid*\fR\fIbuf\fR, \fBsize_t\fR \fIsize\fR); .fi .SH INTERFACE LEVEL .sp .LP Architecture independent level 1 (DDI/DKI). .SH PARAMETERS .sp .ne 2 .mk .na \fB\fIsize\fR\fR .ad .RS 8n .rt Number of bytes to allocate. .RE .sp .ne 2 .mk .na \fB\fIflag\fR\fR .ad .RS 8n .rt Determines whether caller can sleep for memory. Possible flags are \fBKM_SLEEP\fR to allow sleeping until memory is available, or \fBKM_NOSLEEP\fR to return \fINULL\fR immediately if memory is not available. .RE .sp .ne 2 .mk .na \fB\fIbuf\fR\fR .ad .RS 8n .rt Pointer to allocated memory. .RE .SH DESCRIPTION .sp .LP The \fBkmem_alloc()\fR function allocates \fIsize\fR bytes of kernel memory and returns a pointer to the allocated memory. The allocated memory is at least double-word aligned, so it can hold any C data structure. No greater alignment can be assumed. \fIflag\fR determines whether the caller can sleep for memory. \fBKM_SLEEP\fR allocations may sleep but are guaranteed to succeed. \fBKM_NOSLEEP\fR allocations are guaranteed not to sleep but may fail (return \fINULL\fR) if no memory is currently available. The initial contents of memory allocated using \fBkmem_alloc()\fR are random garbage. .sp .LP \fBkmem_alloc\fR should never be called (regardless of \fBKM_SLEEP\fR or \fBKM_NOSLEEP\fR allocations) while holding a spin lock. Note that \fBkmem_alloc\fR can block even when the \fBKM_NOSLEEP\fR flag is provided. .sp .LP The \fBkmem_zalloc()\fR function is like \fBkmem_alloc()\fR but returns zero-filled memory. .sp .LP The \fBkmem_free()\fR function frees previously allocated kernel memory. The buffer address and size must exactly match the original allocation. Memory cannot be returned piecemeal. .SH RETURN VALUES .sp .LP If successful, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return a pointer to the allocated memory. If \fBKM_NOSLEEP\fR is set and memory cannot be allocated without sleeping, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return \fINULL\fR. .SH CONTEXT .sp .LP The \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR functions can be called from interrupt context only if the \fBKM_NOSLEEP\fR flag is set. They can be called from user context with any valid \fIflag\fR. The \fBkmem_free()\fR function can be called from from user, interrupt, or kernel context. .SH SEE ALSO .sp .LP \fBcopyout\fR(9F), \fBfreerbuf\fR(9F), \fBgetrbuf\fR(9F) .sp .LP \fIWriting Device Drivers in Oracle Solaris 11.4\fR .SH WARNINGS .sp .LP Memory allocated using \fBkmem_alloc()\fR is not paged. Available memory is therefore limited by the total physical memory on the system. It is also limited by the available kernel virtual address space, which is often the more restrictive constraint on large-memory configurations. .sp .LP Excessive use of kernel memory is likely to affect overall system performance. Overcommitment of kernel memory will cause the system to hang or panic. .sp .LP Misuse of the kernel memory allocator, such as writing past the end of a buffer, using a buffer after freeing it, freeing a buffer twice, or freeing a null or invalid pointer, will corrupt the kernel heap and may cause the system to corrupt data or panic. .sp .LP The initial contents of memory allocated using \fBkmem_alloc()\fR are random garbage. This random garbage may include secure kernel data. Therefore, uninitialized kernel memory should be handled carefully. For example, never \fBcopyout\fR(9F) a potentially uninitialized buffer. .SH NOTES .sp .LP \fBkmem_alloc(0\fR, \fIflag\fR\fB)\fR always returns \fINULL\fR. \fBkmem_free(NULL, 0)\fR is legal.