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:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top