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
Post a Comment