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 8834905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:08:05+00:00 2026-06-14T09:08:05+00:00

I wrote this program, where in one part, a thread takes char* buffers and

  • 0

I wrote this program, where in one part, a thread takes char* buffers and write them to a pipe
that was created as follows:

 ret_val = mkfifo(lpipename.c_str(), 0666);
 pipehandler = open(lpipename.c_str(), O_RDWR);

then I write to the pipe one buffer after another as follows:

 int size = string(pcstr->buff).length()
 numWritten = write(pipehandler, pcstr->buff, size);

each pcstr->buff is a pointer to a malloc’ed size of a pre-configured size of 1-5 MB

however, it takes too long to write to the pipe , than it does to fill the pcstr->buff (from another source) and it for makes my program run too slow.

Does anyone have any idea of a faster writing method?

Thanks

  • 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-14T09:08:06+00:00Added an answer on June 14, 2026 at 9:08 am

    each pcstr->buff is a pointer to a malloc’ed size of a pre-configured size of 1-5 MB

    Just save the length somewhere. Copying it into std::string just to find out its size is rather wasteful. Or use strlen().

    however, it takes to long to write to the pipe , than it does to fill the pcstr->buff (from another source) and it for makes my program run too slow.

    In Linux the default maximum pipe buffer size is 1Mb as of today. You mentioned you write more than 1Mb into the pipe. When that happens the writing thread blocks till some data from the pipe have been consumed.

    Does anyone have any idea of a faster writing method?

    Use a plain file in /dev/shm or /tmp. On latest Linux’es /tmp is an in-memory filesystem. This only works though, if the amount of data sent through the pipe can be saved in a file without overflowing the amount of free disk space or memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this program: #include <stdio.h> /*Part B Write a program that: defines an
I'm trying to write a program that cleans data, using Matlab. This program takes
I'm trying to understand concurrency in Go. In particular, I wrote this thread-unsafe program:
I wrote this function to communicate with an external program. Such program takes input
Below is the program that I wrote. /******************************************************************************* * This program reads EOF from
I wrote a program called Hello.py that looks like this: import pygame, sys from
I have a program I wrote in Windows with this piece of code that
I wrote this short program which has a tiny GUI. Its supposed to allow
I wrote this small C++ program and built it(Release) #include<iostream> int main(){ std::cout<<Hello World;
I wrote a program to solve a complicated problem. This program is just a

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.