c# - Paralleling trading software (continue) -


i'm not sure if need use such advanced technics plinq that's because rephrase previous question paralleling trading software think previous question complicated , not clear, hope extracted required infromation , nothing else.

i have 2 similar (i identical) threads.

thread1:

while (true)     foreach (object lockobj : lockobjects) {         lock (lockobj) {             // work (may take time)         }     } } 

thread2 (the same, work):

while (true)     // same lockobjects thread1 used threads use "shared" resources     foreach (object lockobj : lockobjects) {         lock (lockobj) {             // work (may take time)         }     } } 

profilier says 30% of processor time i'm waiting lock released. how avoid easily? how say, "ok, if object locked now, postpone object processing, process object, , return object after while?"

one approach maintain queue of free objects, , list of each thread has processed. have threads find first free object queue haven't processed while they're working on it, , put @ end of queue when they're done.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -