Garbage Collection Modern programming languages provide garbage collection mechanisms for reclaiming the memory locations that are no longer used by programs.

Slides:



Advertisements
Similar presentations
Chapter 5: Tree Constructions
Advertisements

Global States.
Handling Deadlocks n definition, wait-for graphs n fundamental causes of deadlocks n resource allocation graphs and conditions for deadlock existence n.
(Chapter 5) Deleting Objects
Resource Management §A resource can be a logical, such as a shared file, or physical, such as a CPU (a node of the distributed system). One of the functions.
Parallel and Distributed Simulation Global Virtual Time - Part 2.
CS 484. Discrete Optimization Problems A discrete optimization problem can be expressed as (S, f) S is the set of all feasible solutions f is the cost.
Garbage Collection What is garbage and how can we deal with it?
Garbage Collecting the World Bernard Lang Christian Queinnec Jose Piquer Presented by Yu-Jin Chia See also: pp text.
Garbage Collecting the World. --Bernard Lang, Christian and Jose Presented by Shikha Khanna coen 317 Date – May25’ 2005.
Garbage Collecting the World: One Car at a Time Richard L. Hudson, Ron Monison,~ J. Eliot B. Moss, & David S. Munrot Department of Computer Science, University.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
Lecture 7: Synchronous Network Algorithms
Memory Management. History Run-time management of dynamic memory is a necessary activity for modern programming languages Lisp of the 1960’s was one of.
Global State Collection. Global state collection Some applications - computing network topology - termination detection - deadlock detection Chandy-Lamport.
1 Complexity of Network Synchronization Raeda Naamnieh.
2015/7/2Deadlock-free Packet Switching1 Introduction to Distributed Algorithm Part One: Protocols Chapter 5- Deadlock-free Packet Switching Teacher: Chun-Yuan.
Distributed process management: Distributed deadlock
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Broadcast & Convergecast Downcast & Upcast
Synchronization (Barriers) Parallel Processing (CS453)
Content Addressable Network CAN. The CAN is essentially a distributed Internet-scale hash table that maps file names to their location in the network.
A correction The definition of knot in page 147 is not correct. The correct definition is: A knot in a directed graph is a subgraph with the property that.
Chapter 7 –System Model – typical assumptions underlying the study of distributed deadlock detection Only reusable resources, only exclusive access, single.
More Distributed Garbage Collection DC4 Reference Listing Distributed Mark and Sweep Tracing in Groups.
Chapter 9 Finding the Optimum 9.1 Finding the Best Tree.
Tree Constructions Distributed Algorithms for Multi-Agent Networks Instructor: K. Sinan YILDIRIM.
Global State Collection
Hwajung Lee. Some applications - computing network topology - termination detection - deadlock detection Chandy Lamport algorithm does a partial job.
1 Chapter 11 Global Properties (Distributed Termination)
Efficient Algorithms for Distributed Snapshots and Global Virtual Time Approximation Author: Friedermann Mattern Presented By: Shruthi Koundinya.
Naming CSCI 6900/4900. Unreferenced Objects in Dist. Systems Objects no longer needed as nobody has a reference to them and hence will not use them Garbage.
GARBAGE COLLECTION Student: Jack Chang. Introduction Manual memory management Memory bugs Automatic memory management We know... A program can only use.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
Garbage Collection What is garbage and how can we deal with it?
Termination detection
Synchronization: Distributed Deadlock Detection
The Echo Algorithm The echo algorithm can be used to collect and disperse information in a distributed system It was originally designed for learning network.
Time and Global States Ali Fanian Isfahan University of Technology
Concepts of programming languages
Chapter 12: Concurrency, Deadlock and Starvation
18-WAN Technologies and Dynamic routing
Routing: Distance Vector Algorithm
Programming Models for Distributed Application
ITEC452 Distributed Computing Lecture 9 Global State Collection
Distributed Snapshot.
Packetizing Error Detection
Distributed Garbage Collection
Packetizing Error Detection
Stacks, Queues, and Deques
Distributed Snapshot.
Graphs.
Time And Global Clocks CMPT 431.
Global State Collection
Packetizing Error Detection
Lecture 8: Synchronous Network Algorithms
Algorithms (2IL15) – Lecture 7
Distributed Deadlock Detection
Graphs.
Graphs.
ITEC452 Distributed Computing Lecture 8 Distributed Snapshot
CSE 380 Lecture Note 12 Insup Lee
Graphs.
Distributed Snapshot.
Graphs.
Chapter 8: Deadlocks Deadlock Characterization
Reference Counting.
Garbage Collection What is garbage and how can we deal with it?
Distributed Snapshot.
Presentation transcript:

Garbage Collection Modern programming languages provide garbage collection mechanisms for reclaiming the memory locations that are no longer used by programs One of the commonly used technique in centralised system is reference counting each object keeps a reference count when the reference to an object is copied, the reference count of the object is incremented when the reference to an object is deleted, the reference count of the object is decremented when the reference count becomes 0, the object can be garbage collected problems with reference counting when applied in a distributed system object might be garbage collected prematurely The problem is due to the messages for incrementing and decrementing count are received out of order 1 5 4 3 2 7 6 1

weighted reference counting An object has a weight assign weight to each pointer object weight = sum of the pointers’ weight when the pointer is copied, evenly distribute the weight When a pointer is deleted, the weight of the pointer is subtracted from the weight of the object An object is garbage collected when its weight becomes to 0 1. problem in an object oriented system 2. reference counting scheme 3. problems on a distributed system 4. assign weight to each pointer 5. when the pointer is copied, evnly distributed the weight 6. when the weight cannot be divided any more, create a new obj Ref counting: when a ref is deleted  count is decrease  when count=0  obj is garbage collect Reference can be copied: count is increased Problem is distributed 2 2 copied 3 1 delete copy Delete arrive first delete 1 Copy arrives later 1 2

2 3 5 copied 10 deleted 10 5 copied 2 3 1 copied 10 5 3 obj weight = sum of the pointer weight When pointer is copied  weight is split No premature garbage collection  weight only decrease, not increase Problem: when weight cannot be divided Cannot collect cyclic garbage 10 5 copied 2 3 1 copied 10 5 3

The weight in an object only decreases It won’t have the problem as the reference counting scheme What if the weight of an object cannot be split? Create an indirection object It cannot handle cyclic garbage How to form a cyclic garbage A.1 = B B.2 = C C.3 = B Free(A)

Collecting cyclic garbage This works as a complement of other garbage collection algorithms, e.g. weighted reference counting) If an object, say A, has a reference to another object, say B, then A is the predecessor of B, and B is A's successor. Let (a) O represent a set of objects, and (b) P be the set of the predecessors of the objects in O. It is easy to see that, if all the objects in O form a cyclic structure, P must be a subset of O. 5

The Algorithm A B C D E root A root object is an operating system object Let O be a set of objects which does not include any root object, and P be the set containing all the predecessors of the objects in O. If P O, then objects in O are garbage. a. garbage include the ones only referenced from a cycle A B C D E root 6

The algorithm is going to pass some probes to discover the predecessor relationship garbage include the ones only referenced from a cycle Assume token starts from B A B C D E root 7

The probes will be sent back to the initiator of the algorithm How do we know whether we have received all the probes so that we can start looking for cyclic structures? Each probe carries some weight. When a probe p is split into n probes, p1, p2, ..., pn, all the (object, predecessor) pairs in p are copied to p1, p.w = p1.w + p2.w + ... + pn.w, pi.initiator = p.initiator where 1 ≤ i ≤ n. How do we know whether we have found all the predecessors of a node? Compare the weight of the node and the sum of the weight of the references to the node (assume the weighted reference counting is used) a. receive a probe, split and send to the successor b. receive a probe with the same initiator again, send to the initiator Assume A initiates the algorithm and carries initial weight 10 A B C D E 8

review What problem does the reference counting garbage collection algorithm might have in a distributed system? Describe how the weighted reference counting garbage collection algorithm works. Why does the weighted reference counting garbage collection algorithm not have the problem encountered by the reference counting garbage collection algorithm? Understand how the algorithm for detecting cyclic garbage works. In the algorithm for collecting cyclic garbage, how do we know whether the probes have reached an object through all the predecessors of the object? [hint: the algorithm works as a complement of other garbage collection algorithms, e.g. weighted reference counting ] Use the principles of the weighted reference counting to develop an algorithm that finds a set of nodes in a wait-for graph such that the outgoing edges from the nodes in this set always end on nodes in this set. (it would be possible to detect deadlock in the OR deadlock model using this algorithm) In the algorithm for collecting cyclic garbage, how do we know whether the probes have reached an object through all the predecessors of the object? [hint: the algorithm works as a complement of other garbage collection algorithms, e.g. weighted reference counting ] To find out whether the probes reach the node through all the predecessors, we can also collect the weight the pointers (i.e. the predecessor) through which the probe arrives. Then, we can check whether the sum of the pointers through which the probes arrive is equal to the weight of the object Use the principles of the algorithm for detecting cyclic garbage to develop an algorithm that finds a set of nodes in a wait-for graph such that the outgoing edges from the nodes in this set always end on nodes in this set: The algorithm works in such a way that probes are passed along the edges in the wait-for graph. The probe is dropped if it reaches a process that is waiting for another process. If the algorithm terminates (i.e. all the probes are returned to the initiator), there is a knot.

Further reading P.Watson and I.Watson. An efficient garbage collection scheme for parallel computer architectures.PARLE'87, LNCS 259:432-443, Springer Verlag, 1987 (weighted reference counting) X.Ye , J. Keane, Collecting Cyclic Garbage in Distributed Systems, Proceedings of the 1997 International Symposium on Parallel Architectures, Algorithms and Networks