473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Multithreading implementation -- assign thread to a specific processor?

Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET? Can't
seem to find anything that would not include such support? API (aka
unmanaged) solution?

Thanks, Rob.
Nov 21 '05 #1
3 5604
In article <ub**************@TK2MSFTNGP11.phx.gbl>, Rob R. Ainscough wrote:
Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET? Can't
seem to find anything that would not include such support? API (aka
unmanaged) solution?

Thanks, Rob.


Maybe System.Thread.ProcessorAffinity?

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 2 Build 2600
System Up Time: 25 Days, 0 Hours, 33 Minutes, 47 Seconds
Nov 21 '05 #2
"Rob R. Ainscough" <ro*****@pacbell.net> schrieb:
Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET?


(Based on a post by Thomas Scheidegger [MVP].)

'Process.ProcessorAffinity'
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessClassProcessorAffinit yTopic.asp>

'ProcessThread.ProcessorAffinity'
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessThreadClassProcessorA ffinityTopic.asp>

'ProcessThread.IdealProcessor'
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessThreadClassIdealProce ssorTopic.asp>

Determining the number of processors:

\\\
Imports System
..
..
..
.... = Environment.GetEnvironmentVariable("NUMBER_OF_PROC ESSORS")
///

..NET 2.0: 'Environment.ProcessorCount'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Thank you, exactly what I needed. .NET 2.0 -- perfect!

Rob.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
"Rob R. Ainscough" <ro*****@pacbell.net> schrieb:
Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET?


(Based on a post by Thomas Scheidegger [MVP].)

'Process.ProcessorAffinity'
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessClassProcessorAffinit yTopic.asp>

'ProcessThread.ProcessorAffinity'
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessThreadClassProcessorA ffinityTopic.asp>

'ProcessThread.IdealProcessor'
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessThreadClassIdealProce ssorTopic.asp>

Determining the number of processors:

\\\
Imports System
.
.
.
... = Environment.GetEnvironmentVariable("NUMBER_OF_PROC ESSORS")
///

.NET 2.0: 'Environment.ProcessorCount'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Harold Howe | last post by:
Howdy, 1- Are property reads in effect volatile? Or is the compiler allowed to optimize property reads away? ie class foo { public int bar { get { return m_bar;}
47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
6
by: David | last post by:
Hi all, In my code I have a bottleneck which consists of a cpu-intensive loop of size LENGTH. What I did was to divide that loop into two threads, Thread1 doing the 0 to LENGTH/2 part, and...
10
by: Ioannis Vranos | last post by:
In .NET multithreading we have to assign a thread to a method of a separate object each time (and not two methods of the same object)? In other words, why does this hung? #using...
5
by: mrkbrndck | last post by:
Please see the code below as I am trying to use multithreading for copying files to a new location in a way that improves performance of the client windows application. The problem occurs when 2...
5
by: He Shiming | last post by:
Hi All, I've got a question regarding using STL map and set class in a multithreaded situation. I'm developing a database program. The program fetches and parses millions of records from the...
4
by: Michael | last post by:
Hi, I am trying to create a multithreaded VB 2005 application which attempts to create a new thread per Domain Controller (DC) in my environment. Each thread connects to its allocated DC and...
2
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.