Click here to Skip to main content
15,911,646 members
Home / Discussions / C#
   

C#

 
QuestionLockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix6-Jan-09 20:52
Cyrilix6-Jan-09 20:52 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Luc Pattyn6-Jan-09 22:58
sitebuilderLuc Pattyn6-Jan-09 22:58 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix6-Jan-09 23:28
Cyrilix6-Jan-09 23:28 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Luc Pattyn6-Jan-09 23:36
sitebuilderLuc Pattyn6-Jan-09 23:36 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix7-Jan-09 1:18
Cyrilix7-Jan-09 1:18 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Luc Pattyn7-Jan-09 1:58
sitebuilderLuc Pattyn7-Jan-09 1:58 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Daniel Grunwald7-Jan-09 2:37
Daniel Grunwald7-Jan-09 2:37 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix7-Jan-09 9:02
Cyrilix7-Jan-09 9:02 
Yes, I include everything when timing. I also saw that count could be eliminated to no negative effect on the algorithm itself. I just wouldn't have anything to keep track of approximately what the count is, which is OK.

The hardware that I'm running it on is an Athlon64 X2 4400+ (2.2 GHz) with 2 cores and no hyper-threading. One thing I did was instead of slowing down the retry, I slowed down the enqueue/dequeue rate, by adding some other intensive math in between. This reduces the contention rate significantly. Before, I'd have about 50% extra operations... slowing it down to a reasonable level drops the amount of additional operations down to 4-6%. Under such a case, the lockless algorithm is equal or better to the lock algorithm.

One question though, what do you mean to imply when you say "With lockless code, when multiple threads us CompareExchange concurrently, at least one will succeed." Isn't it the same with locks? When multiple threads try to enter a critical section, at least one, and only one will succeed. The others will wait their turn.
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
ben.Kloosterman2-Feb-10 19:53
ben.Kloosterman2-Feb-10 19:53 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix3-Feb-10 7:40
Cyrilix3-Feb-10 7:40 
Questionconverting c header file in c# Pin
lawrenceinba6-Jan-09 20:31
lawrenceinba6-Jan-09 20:31 
AnswerRe: converting c header file in c# Pin
N a v a n e e t h6-Jan-09 20:48
N a v a n e e t h6-Jan-09 20:48 
AnswerRe: converting c header file in c# Pin
Guffa6-Jan-09 20:52
Guffa6-Jan-09 20:52 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 20:59
lawrenceinba6-Jan-09 20:59 
GeneralRe: converting c header file in c# Pin
N a v a n e e t h6-Jan-09 21:14
N a v a n e e t h6-Jan-09 21:14 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 21:19
lawrenceinba6-Jan-09 21:19 
GeneralRe: converting c header file in c# Pin
Dragonfly_Lee6-Jan-09 22:24
Dragonfly_Lee6-Jan-09 22:24 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 22:35
lawrenceinba6-Jan-09 22:35 
GeneralRe: converting c header file in c# Pin
Dragonfly_Lee6-Jan-09 22:46
Dragonfly_Lee6-Jan-09 22:46 
AnswerRe: converting c header file in c# Pin
Rob Philpott6-Jan-09 23:00
Rob Philpott6-Jan-09 23:00 
GeneralRe: converting c header file in c# Pin
Luc Pattyn6-Jan-09 23:11
sitebuilderLuc Pattyn6-Jan-09 23:11 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 23:27
lawrenceinba6-Jan-09 23:27 
QuestionFast string to integer conversion Pin
HosamAly6-Jan-09 19:58
HosamAly6-Jan-09 19:58 
AnswerRe: Fast string to integer conversion Pin
N a v a n e e t h6-Jan-09 21:10
N a v a n e e t h6-Jan-09 21:10 
GeneralRe: Fast string to integer conversion Pin
HosamAly6-Jan-09 22:29
HosamAly6-Jan-09 22:29 

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.