Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multithreading / CPU Cores in .Net

Posted on 2008-10-30
3
Medium Priority
?
354 Views
Last Modified: 2012-05-05
Hi!

I'm working on a application/applications that consists of several processes and I wonder  how it works with the processes and the CPU cores, can I point a process to a specific core or is the OS that handles all that?

Why I ask is because  some of the processes (exe files) handles heavy math calculations and I like these processes not to work on the same core as the other processes.

I'm don't know how this  process/multithreading works when it comes to how these resources  are handled by the CPU cores, so I need some help to explain this.

Thx guys
0
Comment
Question by:AWestEng
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 22839199
You can take a look at System.Thread.ProcessorAffinity
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.processoraffinity.aspx


ProcessorAffinity has its value documented in MSDN - look at the remarks section. It's a simple bitmask. http://msdn2.microsoft.com/en-us/library/system.diagnostics.processthread.processoraffinity.aspx

IdealProcessor is also documented in MSDN - again look at the remarks section. It appears to be a simple counter (i.e. 1 is processor 1, 2 is processor 2 etc). http://msdn2.microsoft.com/en-us/library/system.diagnostics.processthread.idealprocessor.aspx

An interesting blog about this subject (with examples)
Spike Your CPUs Processor in .Net
http://www.omegacoder.com/?p=94
Determining the number of processors:
 
\\\
Imports System
..
..
..
.... = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS")
///
 
..NET 2.0: 'Environment.ProcessorCount'.

Open in new window

0
 
LVL 1

Author Comment

by:AWestEng
ID: 22839330
Thx Dhaest: :)
 
0
 
LVL 1

Author Closing Comment

by:AWestEng
ID: 31511578
Thx for all the great examples :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question