Shared Memory, shared struct between multiple processes

Source: Internet
Author: User

Shared Memory Structure, multi-thread multi-process sharing.

# Define file_msg_key0xc54be5 // <file Message key. # define proc_mem_size 4096*3 # define max_1__proc9 # define ipc_creat 00001000/* create if key is nonexistent */static int mfileid, qfileid; static void * psharemem; int psharememinit (INT key) {int mid = shmget (Key, proc_mem_size * max_0000_proc, ipc_creat | 0660); printf ("shared memory size % d \ n", proc_mem_size * max_0000_proc); If (mid <0) mid = shmget (Key, 0, 0); printf ("Shared Memory ID: % d \ n", mid); If (mid <0) Return-1; return mid;} int readsysinfocfg () {mfileid = psharememinit (file_msg_key); If (mfileid <0) Return-1; psharemem = shmat (mfileid, 0, 0 ); sysinfo * psysinfo = (sysinfo *) psharemem ;}



Shared Memory, shared struct between multiple processes

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.