Linux Shared memory

Source: Internet
Author: User

1) Use the Ftok () function to obtain an ID number.
2) Shmget () function to open/point to a piece of shared memory
3) Shmat () maps this memory area to the virtual address space of the process.
4) The SHMDT () function removes the use of this memory by this process
5) Shmctl () controls the use of this shared memory

1) mmap () system calls enable shared memory between processes by mapping the same common file. After the normal file is mapped to the process address space, the process can access the file like normal memory without having to
Call Read (), write (), and so on
2) system call Munmap () unlocks a mapping relationship in the process address space, addr is the address returned when calling Mmap (), and Len is the size of the map area. When the mapping relationship is lifted, access to the original mapped address causes a segment error to occur
3 General process changes to shared content in the mapping space are not directly written back to the disk file, and are often performed after the call to Munmap (). You can implement the content of the file on disk by calling Msync () to match the contents of the shared memory area



Linux Shared memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.