Click here to Skip to main content
15,908,444 members
Home / Discussions / C#
   

C#

 
GeneralRe: xml Pin
Not Active16-Feb-10 12:18
mentorNot Active16-Feb-10 12:18 
Questioncopy datagridview to another datagridview Pin
jashimu16-Feb-10 6:03
jashimu16-Feb-10 6:03 
AnswerRe: copy datagridview to another datagridview Pin
dan!sh 16-Feb-10 6:06
professional dan!sh 16-Feb-10 6:06 
GeneralRe: copy datagridview to another datagridview Pin
jashimu16-Feb-10 6:52
jashimu16-Feb-10 6:52 
QuestionIMessageFilter to capture click event Pin
nuttynibbles16-Feb-10 5:45
nuttynibbles16-Feb-10 5:45 
AnswerRe: IMessageFilter to capture click event Pin
dan!sh 16-Feb-10 6:02
professional dan!sh 16-Feb-10 6:02 
GeneralRe: IMessageFilter to capture click event Pin
nuttynibbles17-Feb-10 0:12
nuttynibbles17-Feb-10 0:12 
Questionsave a picture Pin
naghoumeh1416-Feb-10 4:50
naghoumeh1416-Feb-10 4:50 
AnswerRe: save a picture Pin
Pete O'Hanlon16-Feb-10 4:57
mvePete O'Hanlon16-Feb-10 4:57 
GeneralRe: save a picture Pin
naghoumeh1416-Feb-10 5:05
naghoumeh1416-Feb-10 5:05 
GeneralRe: save a picture Pin
Saksida Bojan16-Feb-10 10:37
Saksida Bojan16-Feb-10 10:37 
QuestionIDWedge ID Scanner Reading Sample application Pin
Tiger45616-Feb-10 4:48
Tiger45616-Feb-10 4:48 
QuestionRPC Error Pin
Syed Shahid Hussain16-Feb-10 4:39
Syed Shahid Hussain16-Feb-10 4:39 
AnswerRe: RPC Error Pin
Dimitri Witkowski16-Feb-10 9:07
Dimitri Witkowski16-Feb-10 9:07 
GeneralRe: RPC Error Pin
Syed Shahid Hussain16-Feb-10 10:30
Syed Shahid Hussain16-Feb-10 10:30 
GeneralRe: RPC Error Pin
Dimitri Witkowski16-Feb-10 10:47
Dimitri Witkowski16-Feb-10 10:47 
GeneralRe: RPC Error Pin
Syed Shahid Hussain16-Feb-10 11:00
Syed Shahid Hussain16-Feb-10 11:00 
GeneralRe: RPC Error Pin
Dimitri Witkowski16-Feb-10 18:09
Dimitri Witkowski16-Feb-10 18:09 
QuestionGrouping elements by memory words: possible? Pin
blackblizzard16-Feb-10 3:29
blackblizzard16-Feb-10 3:29 
Hi everyone.

I'm translating some code from C++ to C# and I've run into a big problem due to the fact that C# is managed and I cannot get the address of the objects I'm handling. (I'm a complete C# newbie so correct me if I'm wrong; I hope I am).

Here's the thing: I'm translating a system that underlies applications and makes sure accesses to shared data are done safely (handles concurrent accesses, etc). For that, whenever a position of the shared memory is accessed there are some measures to be taken, and locks are involved. Memory is segmented so that each 4 words share a lock (too fine a granularity creates high overhead; too coarse, and it greatly reduces parallelism) -- and this is the problem for me. The address of the accessed element is used to map to the lock, but I cannot use addresses in C#, since the garbage collector may relocate objects, etc. I could pin them, but I doubt that would do any good performance-wise.

Instead of addresses I've considered using hash codes (with RuntimeHelpers.GetHashCode), but then I have no way (that I can think of) to control how many memory elements map to the same lock. When using addresses you just shift the address 4 positions to the right, and then you know that you have 4 words mapping to the same lock (assuming addressing by byte and a 32-bit processor), but if you just take a hash code and shift it 4 bits you may end up with very irregular mappings, since hash codes don't need to be consecutive, etc. You may end up with a lock that is mapped by 10 words, and another by 1 or none... This is important for both perfomance and parallelism.

Please tell me that I'm wrong. Smile | :)
Is there a way to do something similar in C#?
Thanks.
AnswerRe: Grouping elements by memory words: possible? Pin
Pete O'Hanlon16-Feb-10 4:11
mvePete O'Hanlon16-Feb-10 4:11 
GeneralRe: Grouping elements by memory words: possible? Pin
blackblizzard16-Feb-10 4:21
blackblizzard16-Feb-10 4:21 
AnswerRe: Grouping elements by memory words: possible? Pin
Luc Pattyn16-Feb-10 6:29
sitebuilderLuc Pattyn16-Feb-10 6:29 
GeneralRe: Grouping elements by memory words: possible? Pin
blackblizzard16-Feb-10 8:12
blackblizzard16-Feb-10 8:12 
QuestionHow i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
Nematjon Rahmanov16-Feb-10 2:33
Nematjon Rahmanov16-Feb-10 2:33 
AnswerRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
Keith Barrow16-Feb-10 2:38
professionalKeith Barrow16-Feb-10 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.