CINXE.COM
shm_overview
<html> <head> <title>shm_overview</title> <META NAME="KEYWORDS" CONTENT="shm_overview"> </head> <body BGCOLOR="#ffffff" LINK="#0000ff" VLINK="#0000ff" ALINK="#0000ff" TEXT="#000000"> <center> <h1><b>shm_overview</b></h1></center> <PRE> <STRONG><A HREF="/man7/SHM_OVERVIEW">SHM_OVERVIEW(7)</A></STRONG> Linux Programmer's Manual <STRONG><A HREF="/man7/SHM_OVERVIEW">SHM_OVERVIEW(7)</A></STRONG> NAME shm_overview - overview of POSIX shared memory DESCRIPTION The POSIX shared memory API allows processes to communicate information by sharing a region of memory. The interfaces employed in the API are: <STRONG><A HREF="/man3/shm_open">shm_open(3)</A></STRONG> Create and open a new object, or open an existing ob- ject. This is analogous to <STRONG><A HREF="/man2/open">open(2)</A></STRONG>. The call returns a file descriptor for use by the other interfaces listed below. <STRONG><A HREF="/man2/ftruncate">ftruncate(2)</A></STRONG> Set the size of the shared memory object. (A newly cre- ated shared memory object has a length of zero.) <STRONG><A HREF="/man2/mmap">mmap(2)</A></STRONG> Map the shared memory object into the virtual address space of the calling process. <STRONG><A HREF="/man2/munmap">munmap(2)</A></STRONG> Unmap the shared memory object from the virtual address space of the calling process. <STRONG><A HREF="/man3/shm_unlink">shm_unlink(3)</A></STRONG> Remove a shared memory object name. <STRONG><A HREF="/man2/close">close(2)</A></STRONG> Close the file descriptor allocated by <STRONG><A HREF="/man3/shm_open">shm_open(3)</A></STRONG> when it is no longer needed. <STRONG><A HREF="/man2/fstat">fstat(2)</A></STRONG> Obtain a stat structure that describes the shared memory object. Among the information returned by this call are the object's size (st_size), permissions (st_mode), owner (st_uid), and group (st_gid). <STRONG><A HREF="/man2/fchown">fchown(2)</A></STRONG> To change the ownership of a shared memory object. <STRONG><A HREF="/man2/fchmod">fchmod(2)</A></STRONG> To change the permissions of a shared memory object. Versions POSIX shared memory is supported since Linux 2.4 and glibc 2.2. Persistence POSIX shared memory objects have kernel persistence: a shared memory object will exist until the system is shut down, or until all processes have unmapped the object and it has been deleted with <STRONG><A HREF="/man3/shm_unlink">shm_unlink(3)</A></STRONG> Linking Programs using the POSIX shared memory API must be compiled with cc -lrt to link against the real-time library, librt. Accessing shared memory objects via the filesystem On Linux, shared memory objects are created in a (<STRONG><A HREF="/man5/tmpfs">tmpfs(5)</A></STRONG>) virtual filesystem, normally mounted under /dev/shm. Since kernel 2.6.19, Linux supports the use of access control lists (ACLs) to control the permissions of objects in the virtual filesystem. NOTES Typically, processes must synchronize their access to a shared memory object, using, for example, POSIX semaphores. System V shared memory (<STRONG><A HREF="/man2/shmget">shmget(2)</A></STRONG>, <STRONG><A HREF="/man2/shmop">shmop(2)</A></STRONG>, etc.) is an older shared memory API. POSIX shared memory provides a simpler, and better de- signed interface; on the other hand POSIX shared memory is somewhat less widely available (especially on older systems) than System V shared memory. SEE ALSO <STRONG><A HREF="/man2/fchmod">fchmod(2)</A></STRONG>, <STRONG><A HREF="/man2/fchown">fchown(2)</A></STRONG>, <STRONG><A HREF="/man2/fstat">fstat(2)</A></STRONG>, <STRONG><A HREF="/man2/ftruncate">ftruncate(2)</A></STRONG>, <STRONG><A HREF="/man2/mmap">mmap(2)</A></STRONG>, <STRONG><A HREF="/man2/mprotect">mprotect(2)</A></STRONG>, <STRONG><A HREF="/man2/munmap">munmap(2)</A></STRONG>, <STRONG><A HREF="/man2/shmget">shmget(2)</A></STRONG>, <STRONG><A HREF="/man2/shmop">shmop(2)</A></STRONG>, <STRONG><A HREF="/man3/shm_open">shm_open(3)</A></STRONG>, <STRONG><A HREF="/man3/shm_unlink">shm_unlink(3)</A></STRONG>, sem_over- <STRONG><A HREF="/man7/view">view(7)</A></STRONG> COLOPHON This page is part of release 5.05 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2016-12-12 <STRONG><A HREF="/man7/SHM_OVERVIEW">SHM_OVERVIEW(7)</A></STRONG></PRE> <center> <h6>Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2025 <a href="http://www.he.net">Hurricane Electric</a>. All Rights Reserved.</h6></center> </body> </html>