Maximizing Dual Core Performance in Visual Studio

Click For Summary

Discussion Overview

The discussion revolves around maximizing dual-core performance in Visual Studio when programming in C/C++. Participants explore the use of multithreading to enhance program execution efficiency across both cores.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant notes that their dual-core Intel Centrino processor only utilizes one core when running programs in Visual Studio, questioning whether it is possible to leverage both cores.
  • Another participant suggests that using threads can allow for concurrent execution, enabling both cores to be utilized effectively, but acknowledges that multithreading is complex and not all tasks can be parallelized.
  • A subsequent reply indicates that for the specific type of program being discussed, threads may not be necessary.
  • One participant shares an example of a multi-threaded program that demonstrates file copying using two threads, detailing the implementation of threads, mutexes, semaphores, and inter-thread communication techniques.

Areas of Agreement / Disagreement

Participants express differing views on the necessity and applicability of multithreading for the discussed programming scenario, indicating that there is no consensus on whether threads are required for all types of programs.

Contextual Notes

The discussion does not resolve the complexities of multithreading or the specific conditions under which it may or may not be beneficial for different types of programs.

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:

Similar threads

  • · Replies 25 ·
Replies
25
Views
15K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
4
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 13 ·
Replies
13
Views
6K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
1
Views
8K