Maximizing Dual Core Performance in Visual Studio

AI Thread Summary
A dual-core Intel Centrino processor can run programs in Visual Studio, but often only one core is utilized due to the single-threaded nature of many applications. To leverage both cores, developers need to implement multithreading, which allows multiple tasks to run simultaneously. This involves creating threads that can perform different operations concurrently, such as reading and writing files in a multithreaded program example. Key concepts in multithreading include using mutexes for resource management, semaphores for signaling between threads, and functions like WaitForMultipleObjects() for efficient thread coordination. While multithreading can enhance performance, it requires a solid understanding of its complexities, and not all tasks are suitable for this approach. A sample multithreaded program demonstrating these principles is available for download.
madmike159
Gold Member
Messages
369
Reaction score
0
My laptop has a duel core Intel Centrino processor. Whenever I write programs in C/C++ in Visual Studio and run programs which should execute at full speed only one core seems to be doing anything. Some programs seem to be able to make full use of both cores, is this possible in Visual Studio?
 
Technology news on Phys.org
You need to learn to use "threads".

Each core is logically a different processor and will always be executing something different from the other. Since your code is only ever doing one thing at a time, there is only work for one processor. Threads allow you to "do two things at once" so that the other processor has something to do. Note, multithreading is a large and complex subject, there are several things you will need to learn to do it properly and not all tasks can be multithreaded.
 
Ok thanks. For the kind of program I was talking about threads won't be necessary.
 
I made an example multi-threaded program for Visual Studio C/C++. It just copies a file, using one thread to read the source file, and a second thread to write the copy. It shows how to: create threads, use mutexes, use semapahores, use waitformultipleobjects(), and implements linked list fifo messaging used for inter-thread communication (the list elements contain ptrs to buffers and counts). Waitformultipleobject(), is a nice feature, it allows a thread to make a single atomic (non-interruptable) call to the system, to get ownership of a fifo (mutex), and wait for non-zero count (semaphore), and decrement the fifo count (semaphore), eliminating any thread priority issues. The setup is a bit complicated, but the actual thread code is very simple.

http://rcgldr.net/misc/mtcopy.zip
 
Last edited:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top