Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
Abhinav S16-Feb-10 2:59
Abhinav S16-Feb-10 2:59 
QuestionRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
Nematjon Rahmanov16-Feb-10 3:11
Nematjon Rahmanov16-Feb-10 3:11 
AnswerRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? [modified] Pin
Hristo-Bojilov16-Feb-10 3:19
Hristo-Bojilov16-Feb-10 3:19 
AnswerRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
danberlove16-Feb-10 4:50
danberlove16-Feb-10 4:50 
GeneralRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
DaveyM6916-Feb-10 6:13
professionalDaveyM6916-Feb-10 6:13 
AnswerRe: How i can protect my C# app Reflector (Red Gate) and other disassemblers ? Pin
harold aptroot16-Feb-10 7:25
harold aptroot16-Feb-10 7:25 
QuestionAdding 2 Zeros after each byte in textbox Pin
xEvOx16-Feb-10 1:29
xEvOx16-Feb-10 1:29 
AnswerRe: Adding 2 Zeros after each byte in textbox Pin
Rob Philpott16-Feb-10 1:53
Rob Philpott16-Feb-10 1:53 
AnswerRe: Adding 2 Zeros after each byte in textbox Pin
Richard MacCutchan16-Feb-10 2:39
mveRichard MacCutchan16-Feb-10 2:39 
GeneralRe: Adding 2 Zeros after each byte in textbox Pin
Rajesh Anuhya16-Feb-10 2:51
professionalRajesh Anuhya16-Feb-10 2:51 
AnswerRe: Adding 2 Zeros after each byte in textbox Pin
Rajesh Anuhya16-Feb-10 2:50
professionalRajesh Anuhya16-Feb-10 2:50 

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.