54
edits
Changes
→Updated page structure
*''All notes are based on the material outlined in "Debug Multithreaded Applications in Visual Studio" section of MSDN documentation at:'' [https://msdn.microsoft.com/en-us/library/ms164746.aspx https://msdn.microsoft.com/en-us/library/ms164746.aspx] ''and other related MSDN documentation.''
'''Entry on: November 6th 2016by Vadym Karpenko'''
While parallel processing of multiple threads increases program performance, it makes debugging task harder, since we need to track multiple threads instead of just one (Master thread). Also some potential bugs are introduced with parallel processing, for example, when race condition (When multiple processes or threads try to access same resource at the same time, for more information visit [https://en.wikipedia.org/wiki/Race_condition Race Condition Wiki]) occurs and mutual exclusion is performed incorrectly, it may create a deadlock condition (When all threads wait for the resource and none can execute, for more info visit [https://en.wikipedia.org/wiki/Deadlock Deadlock Wiki]), which can be very difficult to debug.
Visual Studio provides many useful tools that make multithreaded debugging tasks easier.
A process is a task or a program that is executed by operating system, while a thread is a set of instructions to be executed within a process. A process may consist of one or more threads.
Configuration:
# To change how Stop Debugging affects attached processes, open to Processes window (Crtl + Alt + Z), right click on individual process and check/un-check the "Detach when debugging stopped" check box;
'''Entry on: November 9th 2016by Vadym Karpenko'''
Threads window columns:
Thread name can be set using SetThreadName function provided by Microsoft:
Parallel Watch window columns: