Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:10:29+00:00 2026-06-11T10:10:29+00:00

Motivation I’d like to write a pair of programs where one program reads data

  • 0

Motivation

I’d like to write a pair of programs where one program reads data and transfers it into an internal format and the other program transfers the internal format into something else. As an excercise, I want to code the interaction between these programs without the use of pipes. I rather like to use signals and shared memory.

What I want

I have programs A and B where A calls B. How can I

  1. Create a memory block from program A
  2. Call program B from program A, giving it the information about where to find the memory block
  3. Use the memory block from both programs.

More specific, A decodes a custom video format and places a single uncompressed frame into a shared buffer. B reads from the buffer and encodes it into an output strean. The decoder decodes up to 100 frames per second which is about 500 MiB/s memory traffic. Pipes turned out to be slow since the data has to be copyied much too often and the buffers aren’t exactly big.

What I think might work

My idea is to use mmap(NULL,len,PROT_READ|PROT_WRITE,MAP_SHARED|MAP_ANONYMOUS,-1,0) to create a section of shared memory. The problem is, that the manpage of execve(2) states:

Memory mappings are not preserved (mmap(2)).

So, how can I share that memory with the other program? Is it a better idea to put both functionality into one program and use fork instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:10:30+00:00Added an answer on June 11, 2026 at 10:10 am

    *nix systems have several APIs for shared memory:

    • BSD: use mmap(). To share memory between unrelated processes, you associate it to a file. You can also share memory between related processes using MAP_ANONYMOUS and fork()ing (but make sure to use -1 as fd for portability).
    • System V: (some people really dislike this one) use shmget() to create/get a reference to a shared memory area, attach to it via shmat(), detach via shmdt(), mark for deletion with shmctl(). You identify shared memory areas by a key, which should be unique.
    • POSIX: use shm_open() then mmap() from the returned file descriptor.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Motivation: I would like to convert hashes (MD5/SHA1 etc) into decimal integers for the
motivation: I would like to create a utility class so that instead of having
Not looking for the help file, more for the motivation why would one use
Motivation for Question : Generating 64-bit and 32-bit code requires two seperate full-program-compiles, and
Motivation Imagine a huffman compressed file that gets downloaded partially, like in P2P software,
I learned that one of the motivation for copy constructor using is to avoid
Motivation I'd like to find a way to take an arbitrary color and lighten
I'd like to hear what is the motivation behind the bulk of sealed classes
I have two queries like so, $q = $dbc -> prepare(UPDATE accounts SET motivation
Motivation : I often want to paste the results of a quick analysis using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.