Part 97 Performance of a multithreaded program

Text version of the video http://csharp-video-tutorials.blogspo... Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.    / @aarvikitchen5572   Slides http://csharp-video-tutorials.blogspo... All C# Text Articles http://csharp-video-tutorials.blogspo... All C# Slides http://csharp-video-tutorials.blogspo... All Dot Net and SQL Server Tutorials in English https://www.youtube.com/user/kudvenka... All Dot Net and SQL Server Tutorials in Arabic    / kudvenkatarabic   First let's discuss, how to find out how many processors you have on your machine? There are several ways 1. Right click on the Task bar and select "Start Task Manager" option from the context menu. Click on the the performance tab. The number of green boxes under "CPU Usage History" should correspond to the number of processors on the machine. 2. The following code can be used in any .net application to find out the total processors on the machine Environment.ProcessorCount 3. On the windows command prompt window, type the following echo %NUMBER_OF_PROCESSORS% On a machine that has multiple processors, multiple threads can execute application code in parallel on different cores. For example, if there are two threads and two cores, then each thread would run on an individual core.This means, performance is better. If two threads take 10 milli-seconds each to complete, then on a machine with 2 processors, the total time taken is 10 milli-seconds. On a machine that has a single processor, multiple threads execute, one after the other or wait until one thread finishes. It is not possible for a single processor system to execute multiple threads in parallel. Since the operating system switches between the threads so fast, it just gives us the illusion that the threads run in parallel. On a single core/processor machine multiple threads can affect performance negatively as there is overhead involved with context-switching. If two threads take 10 milli-seconds each to complete, then on a machine with 1 processor, the total time taken is 20 milli-seconds + (Thread context switching time, if any)