hottoko

I have a .net 1.1 win app written in c# with at datagrid on is

The grid , - running on the main thread- is showing data from a dataset that is being updated by 2 other threads at the same time, so 3 threads fighting over the same data.

So I use Lock like this

lock(LockObj)

{

Update data

}

It all works fine, until I have to move the app to at Intel DueCore processer PC

Here it breaks.

So me question is, how can I control that all threads is running on the same CPU so that my Locks will work again

Thanks !



Re: Common Language Runtime thread lock on multicore processor

nielsvanvliet

Hi,
Your lock will work even on dual CPU.
You might have another problem. Make sure LockObj is the same accross all threads.

If it works with less thread, it might be because you are just lucky (less threads => less concurrent accesses => less problems).

If this does not answer your question, please explain what is LockObj (a static variable, this, ...).






Re: Common Language Runtime thread lock on multicore processor

vtortola

Put more code, i think as nielsvanvliet because i develop over SMP machines and 'lock' statement runs fine.

How it breaks A exception a deadlock

Although your develop machine don't have two processors, have cpu scheduling and the effect is similar , you also must control the concurrency.

Regards.






Re: Common Language Runtime thread lock on multicore processor

hottoko

setting the ProcessAfinity for the process and all the threads to the same CPU seams to have solved the problem

Thanx





Re: Common Language Runtime thread lock on multicore processor

Greg Beech

hottoko wrote:

setting the ProcessAfinity for the process and all the threads to the same CPU seams to have solved the problem

Thanx

It hasn't really solved the problem, it has bypassed the problem by disallowing concurrent access to the data due to thread scheduling. I can just imagine a conversation with a customer.....

"Why doesn't your application run any faster on a 4-way dual-core server "

"Oh, we couldn't work how to do it properly so we limited it to a single core on a single CPU"

"Ah... I see... "

*click*