multithreading - Traverse a graph in parallel -
I'm amending a test (still) and I have a question (posted below), which I've stumped I think, in a nutshell, the question is asking "Think about any_old_process which does some work to cross a graph and find objects, which involves more work." My question is, what data structure can be parallel to achieve the goals set in question?
The role of a garbage collector (GC) is to recover the unused memory. To trace collectors by crossing graphs of motivated motions inspired by aggregation relationships, all living things must be identified. In summary, there is a work schedule for working in GC; it repeatedly (A) receives a function (for example an object is inspected), (B) works (like mark the object Unless it is not already marked), and (C) generates further tasks (for example, the children of an unmarked work adds to the task list) it is desirable to parallel the operation.
In a single-threaded environment, the task list is usually a single LIFO stack. What do you have to do to make this secure for parallel GC? Will this be a sensible design for parallel GC? To support parallel GC, discuss the design of data structure which will be on a better scale. Explain why you will go to a better scale.
There is a natural data structure for a graph, well, a graph, i.e. graph A set of elements (nodes) that can refer to other elements. However, for better cache reuse, the elements can be placed in arrays or arrays (usually, vectors) so that neighboring elements can be kept close to memory. Generally, there should be a mutex (spin_mutex) to enter each element or group of elements, the dispute means that some other thread is working on it, so there is no need to wait. However, if possible, it is better to flag a nuclear operation element on the flag / state areas, as seen without the lock. For example, the easiest data structure can be:
straight object {vector < Object * & gt; Context; Atom & LT; Bool & gt; Is_visited; // Simplicity, or for the era counter // if nothing is reset to check this false zero; // processing method }; Of vector & lt; Object & gt; Objects; // Even for simplicity, if it can be for parallel_ for real // things, then it would be perfect
considering this data structure and how GC described It's perfectly fit, for instance- for recursive parallelism:
zero object :: inspection (if (is! Is_visited.exchange (true)) {for (object * o: Objects) // Alternatively, it `parallel_for` cilk_spawn o-> in some types; inspection (); // for silk or` tcbb or ppl / For the further process of the object, `workgroup :: run`}}
If the data structure in question is how functions are organized, then I am a work-breaker scheduler To make this easy, each worker thread has its own work, but the work is shared, and when the deck is empty, then a thread stole the job. / P>
Comments
Post a Comment