- Tubelator AI
- >
- Videos
- >
- People & Blogs
- >
- Garbage collection and ABA problem in concurrency with example
Garbage collection and ABA problem in concurrency with example
#Garbage#collection#and#ABA#problem#in#concurrency#with#example#Karanjetlilive#it#lectures
Video Summary & Chapters
No chapters for this video generated yet.
Video Transcript
Hi guys, welcome to my channel and today in this video we are going to discuss garbage
collection and ABA problem in concurrency.
So guys for the full lecture all of you stay tuned.
So guys first thing first what is garbage collection?
So all of you those who study data structures, okay, they must have come across this term.
We call it as garbage collection what it is.
Guys, garbage collection is the process of collecting all the free notes or collecting
all the deleted data and putting them in an available pool.
What is available pool?
Available pool is another step.
structure in which we append all the deleted nodes so that they can be reused.
For example, this is our linked list.
So it has three elements A, A is pointing to B, B is pointing to C. So suppose the address
of A is 100, address of node B is 110, address of node C is 120.
And then we have a start which is pointing to the first node that is 100 and C is not
pointing anywhere so that is none.
Suppose this is my linked list.
Now in this linked list suppose I delete node A. Suppose I delete node A. How do we delete
node A, we delete the node A by changing the address of start.
So earlier it was pointing to 100, now it will point to 110.
Now it will point to 110.
So what will happen?
Automatically this start, instead of pointing to A, it will start pointing to B. And my
linked list will start from the B. So you go to start.
What is the first node?
110 then 120 and so on. A gets deleted from here. A gets deleted from here. Now this is
a deleted node. Okay. This is a deleted node. What is a garbage collection? Garbage collection
is the process in which all such deleted nodes are collected together. Okay. And they are
put in an available list for recycling. Now what is the available list? It is the list
of all the deleted nodes so that whenever we need a new node we can take we can pick
a node from the available list.
So here spool we have a available list A B A I L list.
So avail list now A got deleted avail list will point to A. So what we have here is the
deleted node A.
Now, suppose in this list, in this list, in this list, node B also gets deleted.
How do we delete it?
We change the starting address from 110 to 120.
So what will happen?
The start will point from 110 to 120.
Then what do we do?
Again, we bring this list, again we bring this node B to available list.
So what A will point to?
Now we will modify our available list, A will point to 110.
So what comes here is after A comes and B is pointing to null and available header was
pointing to 110.
So what happened?
from this list I deleted two nodes that was node A and that was node B. So all two nodes they became
where the we I moved them to available list. So from here we can recycle that.
So from here we
can recycle them. For example, after some time again we need to insert a node in our this list.