Sequential and running in one thread time difference 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.
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.

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)?

How does one make something real time? [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.
This might be a really stupid question, but I can't find any info on this, and I can't find out what to search for.
How do you make something real time? For example, say we have a game, how does it run continuously without us calling a tick() method at different parts of the program?
If you are developing the program to run at a time in particular the best way I know of is to develop it to run at a particular loop rate using timed delays.
IE:
while(forever) {
do something
test how long it took
take up the remainder amount of time for the loop to run at a rate (ie 100Hz)
}
If you are desperate for real time applications you can develop and use QNX:
http://www.qnx.com/
But this certainly wouldn't be a good environment for programming games.

Threads and synchronisation using pipe in 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.
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.

CPU caches aware C++ / C programming [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 was going through Scott Meyer's podcast on CPU CACHES AND WHY YOU CARE It seems this will make code run faster, is there any open source where such coding is done for reference.
Or anybody has example of design of data structures/algorithms based on CPU caches aware
Sure, the entire Linux kernel is implemented to be cache-aware.
For more details there is highly recommended paper What Every Programmer Should Know About Memory.
Linear algebra is sensitive to cache problems. The BLAS subroutines allow one to abstract away from these concerns

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.