Threads and synchronisation using pipe in c++ [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have two threads. one thread generate a number and the other squares the number generated. I need to synchronise this action using pipes or semaphore or message queues . Help me with this problem

This is a wrong way to go. Generating an extra thread and synchronizing the two threads would require more CPU power than just squaring the number in the generator thread.
Implementing a pipeline is effective only when each step requires enough computational power to justify the extra thread.
As for your questions, I suggest you should read about the Producer-Consumer pattern. There are many implementations on the wild.

Related

Readers–writer lock Multithreading Scenario? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have read a few links about Readers–writer lock. I had few doubts.
In case the system has to be designed for Multiple reads and single write ,and write should have priority.
In case the system has to be designed for multiple reads and multiple write
So should we be implementing a semaphore for multiple read and a mutex for multiple write? or when do i use a critical section?
Also,Does it depend on the operating system? (does it differ in case of Unix and Windows)?

Sequential and running in one thread time difference c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Here is my source code for testing multithread performance in C++. Please tell me why is time about 5x smaller for ONE thread running(WaitForMultipleObject()) then first sequential performance. I expect almost same result for sequential performance and running with only one thread. Thanks
http://pastebin.com/EeJ5qW03
OS will decide when will your thread start running and it will also decide if there's a need for dispatching, perhaps. Add to that, it also has to create a separate stack for your thread, perhaps.
Read about the overhead on thread creation. All in all, the overhead is system specific.

C++ multiple process shared memory implementation [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Here's what I am trying to accomplish.
I want program1 to create a shared memory segment where I store various arrays.
Then, I want program2 to read in the arrays and modify them.
This sounds pretty simple, but for some reason, I cannot find a single example online that shows how this is done. Every example I have found uses a single program (e.g the initialize, read and write are both done by program1).
If somebody can provide an example here, I'm sure this would be hugely beneficial for pretty much everybody that wants to use IPC in C++.
Boost.Interprocess has a guide for the impatient.

Run "While loop" in background [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have a Credential Provider dll application in C++. Inside this dll i create a process that will write some data in a file. I need somehow to read that data from file till the value is > -1. I can not use a while loop because my dll will stop loading till the while loop will end. Can i use a separate thread to do this and to get a notification to run a function from my dll when the while loop end? How can i do this? Is there a simple way to do this?
Thank you.
The only really practical way to achieve concurrency is using threads. Take a look at boost threads.
If your compiler implements C++0x thread, then you can make use of it.
Read this extensive tutorial on C++0x multi-threading : Multithreading in C++0x part 1: Starting Threads

Of these four libraries, which are you most likely to use? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I'm trying to pick out my next hackery project. It'll likely be one of the following:
A sparse radix trie Implementation with extremely fast set operations
A really good soft heap implementation
A bloomier filter implementation
A collection of small financial algorithms, such as deriving total returns given a set of dividends and minimal information about them.
But I can't choose. So I thought I'd put my fate in the hands of my peers. Which of those four would you find most useful? Most interesting to work on? Which do you think is the most needed?
I didn't know what a bloomier (maybe Bloom?) filter is until reading your question. Sounds cool and useful.