Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

Threading and the new processors

Posted on 05/21/2012 6:20:42 AM PDT by varmintman

Somebody has an ordinary MFC program which uses one or more separate threads to handle disk-intensive activities (AfxBeginThread ( additems, pstr , THREAD_PRIORITY_NORMAL ) or something like that), and he goes out and buys one of the new computers with an I7 chip in it which are now under a thousand dollars USD.....

Assuming he is also using VisualStudio 2010, what exactly happens? is Win 7 bright enough to assign separate processors to separate threads when possible, or do you need to set some build parameter differently from past ages, or do you need a copy of Intel's rich-only-need-apply C++ compiler, or what exactly.

I'd appreciate hearing from anybody who's actually seen this one or has any sort of a clue.


TOPICS: Computers/Internet
KEYWORDS: c; mfc; programming; threading

1 posted on 05/21/2012 6:20:53 AM PDT by varmintman
[ Post Reply | Private Reply | View Replies]

To: varmintman

Sorry. I’m the right guy but my multithread under 2010 is limited. I’d ask Doctor Google.


2 posted on 05/21/2012 6:22:41 AM PDT by Lazamataz (The so-called 'mainstream' media has gone from "biased" straight to "utterly surreal".)
[ Post Reply | Private Reply | To 1 | View Replies]

To: varmintman
Doctor Google says .NET 4.0 has enhanced multithread capability. You can brighten 4.0's IQ by using backgroundworker.

http://msdn.microsoft.com/en-us/library/ck8bc5c6.aspx

3 posted on 05/21/2012 6:25:25 AM PDT by Lazamataz (The so-called 'mainstream' media has gone from "biased" straight to "utterly surreal".)
[ Post Reply | Private Reply | To 1 | View Replies]

To: Lazamataz

.Net may or may not be an option here, not sure. The main dll has to stay MFC, performance concerns as well as concerns with how easy the code would be to disassemble. The part which does threading however is separate from that and converting it to .Net might work if there’s no way to get to using an I7 with MFC code.


4 posted on 05/21/2012 6:35:09 AM PDT by varmintman
[ Post Reply | Private Reply | To 3 | View Replies]

To: varmintman

I ain’t a C++ head, but if you have source, isn’t it nearly a nobrainer to compile to C#? I mean, yeah, pointers and garbage collection, but other than that?


5 posted on 05/21/2012 6:42:14 AM PDT by Lazamataz (The so-called 'mainstream' media has gone from "biased" straight to "utterly surreal".)
[ Post Reply | Private Reply | To 4 | View Replies]

To: Lazamataz

The Background Worker is the new preferred way from what I was reading. With respect to thread dispatch on individual processor cores, you should be able see processor demand curves in perfmon?

I have a multi-threaded c# application I’ve been hacking on for several months, and several things I have noticed in VS 2010 is that debugging is definitely not linear. In fact, the only way I have been able to effectively debug is with log statements. I had to do use lock on a readonly object to single thread through the logger, but it seems to be effective, more or less. At least I’ve been able to generate the application, thank goodness...


6 posted on 05/21/2012 6:46:42 AM PDT by gcraig (Freedom isn't free)
[ Post Reply | Private Reply | To 3 | View Replies]

To: Lazamataz

The interface code could be converted to C#, the function code couldn’t, again performance and P code being too easy to disassemble and then a lot of bit fiddling in code which is more like C than C++ and the C functions probably aren’t there in C#.


7 posted on 05/21/2012 6:51:35 AM PDT by varmintman
[ Post Reply | Private Reply | To 5 | View Replies]

To: gcraig
The Background Worker is the new preferred way from what I was reading. With respect to thread dispatch on individual processor cores, you should be able see processor demand curves in perfmon?

If the drain is large enough, I suppose.

I have a multi-threaded c# application I’ve been hacking on for several months, and several things I have noticed in VS 2010 is that debugging is definitely not linear. In fact, the only way I have been able to effectively debug is with log statements. I had to do use lock on a readonly object to single thread through the logger, but it seems to be effective, more or less. At least I’ve been able to generate the application, thank goodness...

There are a series of pretty good tips on debugging MT apps:

http://msdn.microsoft.com/en-us/library/ms164746.aspx

8 posted on 05/21/2012 6:52:40 AM PDT by Lazamataz (The so-called 'mainstream' media has gone from "biased" straight to "utterly surreal".)
[ Post Reply | Private Reply | To 6 | View Replies]

To: varmintman
the C functions probably aren’t there in C#.

I'm not a 100%, but I'm almost willing to bet you that they are.

C# is VERY rich, VERY robust.

9 posted on 05/21/2012 6:54:06 AM PDT by Lazamataz (The so-called 'mainstream' media has gone from "biased" straight to "utterly surreal".)
[ Post Reply | Private Reply | To 7 | View Replies]

To: varmintman

From what I know C# and .Net handle this. C++ API call has an Affinity Mask that assigns a core when you create the thread.

GOTO Here: http://www.dreamincode.net/forums/topic/52380-multi-threading-on-multi-processors/


10 posted on 05/21/2012 7:29:13 AM PDT by ImJustAnotherOkie (zerogottago)
[ Post Reply | Private Reply | To 1 | View Replies]

To: Lazamataz

Thank you for the multi-threading debug info... now that i understand how to switch threads in the debugger it helped to identify and protect a couple synchronization fixes. Also it is very interesting how you identify thread demand as drain. Do you derive that from the sink /drain programming concepts in Windows? It caught my eye mostly because we describe cpu demand in increasing, or utilization terms. I was wondering about how drain describes it in decreasing, or approaching idle. Do you work in UNIX java environments or do you specialize in Win/.net?


11 posted on 05/27/2012 10:10:47 AM PDT by gcraig (Freedom isn't free)
[ Post Reply | Private Reply | To 8 | View Replies]

To: gcraig

I’m a dot Net guy... glad you got something out of that...


12 posted on 05/27/2012 10:13:37 AM PDT by Lazamataz (The so-called 'mainstream' media has gone from "biased" straight to "utterly surreal".)
[ Post Reply | Private Reply | To 11 | View Replies]

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson