Another example is at the end of the game when Lock is taken to the King, Lock states that he will accept what consequence for what happens to fix Emi, but will not accept the fate that Emi remains broken. Lock is shown to really care for Emi, as when he decided to search for Emi instead of helping Isaiah defend his village before Tobias reminds him that the village depends on him. Lock is also shown to empathy, as proven when Isaiah states that the Eastern Front has lost three Source Wells and feels remorseful for their loss. He can also be seen as determined, shown when he wanted to prove himself to Kenan that Lock can become a Archineer. He is also proven to be hard on himself at some points in the game, specifically after losing or leaving his sister Emi behind. Lock is best described as nice, respectful and caring to his close friends and/or relatives. His pants are gray and his belt, gloves and shoes are golden brown. In the game's sprite, Lock's goggles have a dark violet outline, his scarf is yellow (matching the same pallette as his hair, his shirt is a brighter blue and has sleeves. Unlimited-size queues are "a bit" harder ) But you should be able to create a big-enough queue for most needs.In the artworks, Lock has yellow spiky hair, cobalt blue goggles worn wrapped around his head, a sleeveless blue shirt and a red scarf, shoulder armor on his right arm, bandages wrapped around his arms, a brown belt around his waist, brown gloves, dark blue pants and brown shoes. You can wait on both head and tail CAS operations, but if the queue is not contended, you should succeed the first time, without unnecessary locks. ![]() if CAS failed - start the whole function over.do a CAS: compare head with tmp_head swap head with head+1.if it's true, return because the queue is empty.for dequeue() make a copy tmp_head=head and check tmp_head = tail.otherwise put your ptr in *prev_tail and assign prev_tail+1 to tail (watch out for buffer wrap-around).if prev_tail + 1 (with wraparound) = head, your queue is full.if you want to enqueue(ptr), Interlocked-Swap tail with NULL ( prev_tail is the swapped value).you have to manage 2 pointers (head, tail) which work over the queue in the same way as a circular buffer.the queue is an array of pointers to items.I was thinking about it lately and came up with this design, but you can probably find many other interesting ideas: (WARNING: it might have some issues!) You could probably implement a limited-size queue with least difficulty. How do you avoid another thread changing this information while the other thread is preparing to do so itself? How exactly is this implemented in a lockless way? Or am i better off reading the undecipherability that is a research paper? ) However you still need to get the next head pointer to test that against the tail pointer to see if yo have just modified the tail. I'm just musing at this point (having not read the papers) but you could use this system to update the head and tail pointer simultaneously and thus avoid any issues with another thread jumping inbetween the 2 atomic operations. Has anyone implemented a queue using cmpxchg8b (or cmpxchg16b for that matter)? ![]() However I notice that there are papers at the end that can do the true lockless queue'ing using a double compare-and-swap (DCAS) operation. That would have huge amounts of use for me :)Įdit: Having read herb's DDJ article I can see a reduced lock queue that is pretty similar to the one I already had. I'm unsure how the microsoft implementation works under-the-hood and would love to know more.Ĭan anyone point me towards useful information (Platform and language are pretty irrelevant)?Īdded to that I'd love to know if its possible to implement a lockless vector. Otherwise you are leaving space for another thread to nip in and screw things up. The big problem appears to be that you need to guarantee a list push/pop will use only one Interlocked call. However the actual implementation loses me. ![]() Interlocking on multiple platforms itself is not a problem and I can safely assume I can interlock without problems. Unfortunately, though, I wish to support multiple platforms. I implemented, for testing, a system using the Interlocked SList thing under Win32 and it doubled the performance of my heavily threaded task based code. I have a multiple producer, multiple consumer situation. I've spent today looking into lockless queues.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |