Treetor: tree visualization tool and JDFR

Heteroclinic.net logo

www.heteroclinic.net

Advanced Concurrency Topic:
Runtime Deadlock Detection IX
Tree Graph Analysis 1/4

1.Intrudction

We continue the analysis of deadlock problem by studying the features of tree type graph.

TreeGraphAnalysis.pdf

2.Tree and its number of edges

We can consider a {\it tree} is a graph that has only one root node. From this root node, we can reach any one of the other nodes and the path is unique (the vertexes/nodes edges sequence is unique). Normally we consider tree is un-directed graph. However, if we consider every edge is bi-directional, it will give us great advantage. In the practice of this article, we use the parent node to sub-node direction to construct the graph, the sub-node to parent node direction to uniquely identify a node.

Corollary 2.1 A tree with $n$ nodes has $n-1$ edges, $n \in \mathbb{N}$. 201209corollar2-1.jpg

Advanced Concurrency Topic:
Runtime Deadlock Detection X
Tree Graph Analysis 2/4

3.Tree and connected graph

Corollary 3.1 A connected graph with $n$ nodes and $n-1$ edges is a-cyclic $\iff$ it is a tree, $n \in \mathbb{N}$.

201209corollar3-1.jpg

4.Conclusion from above sections

From the discussion in the above sections, we can draw some very important conclusions. Here, we leave them to the readers as a brain exercise.\\ We show these conclusions in our coding projects.

5.A tree utility program, BFS and DFS traversal

We attach Java program that can be use to construct a tree. After the tree is constructed, we can use BFS or DFS to print the tree. The readers will also see the program will assist the proper construction of a tree.

6.Treetor a snapshot tool

Treetor is a visualization tool of a tree. We use it to render a tree to jpeg file. Unfortunately, it can not create a file has more than 65,500 pixels. In next phase, we will move to OpenGL, theoretically, we will not have a soft limit as javax.imageio.

7.Discussion

This article is not peer reviewed. The attached coding projects are not either. If you find some errors or you want to give some comments, please contact the author. Corollary 2.1 and Corollary 3.1 are not new inventions, you can refer to general computer science or mathematics texts.
Advanced Concurrency Topic:
Runtime Deadlock Detection XI
Tree Graph Analysis 3/4
A tree utility program, BFS and DFS traversal


A small utility program Node.java

Advanced Concurrency Topic:
Runtime Deadlock Detection XII
Tree Graph Analysis 4/4
Treetor a snapshot tool
Treetor is a visualization tool of a tree. We use it to render a tree to jpeg file. Unfortunately, it can not create a file has more than 65500 pixels. In the next phase, we will move to OpenGL, theoretically, we will not have a soft limit as javax.imageio.
treetor.jar
treetorLicesnse.txt

Test.java Case I result 20120901-1348627271569.jpeg

Test.java Case II result
Download, view with a graphics tool like Microsoft paint or GIMP etc. Test.java Case II result


A small test program Test.java

Advanced Concurrency Topic:
Runtime Deadlock Detection XIII
Treetorplus1 and Treetor Functional Requirements 01
Change Graph Orientation
Treetor is a visualization tool of a tree. Now we realease Treetorplus1 treetorplus1.jar,treetorLicesnse.txt

CONSTR-OREINT20121029-001052836.png

CONSTR-OREINT20121029-001053283.png

CONSTR-OREINT20121029-001053495.png

CONSTR-OREINT20121029-001053718.png

Test Case

Advanced Concurrency Topic:
Runtime Deadlock Detection XIV
Treetoplus1 and Treetor Functional Requirements 02
Build a T-Node Tree

TEST_TNODE_TREE20121029-001016390.png

Test Case

Advanced Concurrency Topic:
Runtime Deadlock Detection XV
Treetorplus1 and Treetor Functional Requirements 03
Build a R-Node Tree

TEST_RNODE_TREE20121029-001023730.png

Test Case

Advanced Concurrency Topic:
Runtime Deadlock Detection XVI
Treetorplus1 and Treetor Functional Requirements 04
Build a RT-Node Tree

TEST_RTNODE_animation.gif

Test Case

Advanced Concurrency Topic:
Runtime Deadlock Detection XVII
Treetorplus2 and Treetor Functional Requirements 05
Forest Ministry
Treetor now can render simply forest or basic tree operations. We realease Treetorplus2 treetorplus2.jar,treetorLicesnse.txt

RTNODE_FOREST20121118-211131674.png

Advanced Concurrency Topic:
Runtime Deadlock Detection XVIII
Treetoplus2 Forest Ministry Test Case
Test case of rendering a very simple forest:
Advanced Concurrency Topic:
Runtime Deadlock Detection XIX
Visualization of an Imaginary Concurrency Event
We spent much effort to implement functional requirement 05. What is the purpose for doing such? We attach the following program to show an imaginary concurrent event, which is figured out by the author.
If you would give a name of such event, what will it be?
Such event is good or bad?
In coming episodes, we are going to build real concurrent prototypes to demonstrate such behavior. We may or may not.
Have we demostrated a solution for such behavior in our previous coding projects, implicitly or explicitly?
Please leave your comment!

An imaginary concurrency event, good or bad? What are you trying to do?

Advanced Concurrency Topic:
Runtime Deadlock Detection XX
Visualization Results of XIX
Animation

LIVELOCK_TEST201211.GIF

PNGs:

LIVELOCK_TEST20121118-221151153.png

Figure 01

LIVELOCK_TEST20121118-221151485.png

Figure 02

LIVELOCK_TEST20121118-221151575.png

Figure 03

LIVELOCK_TEST20121118-221151674.png

Figure 04

LIVELOCK_TEST20121118-221151779.png

Figure 05

LIVELOCK_TEST20121118-221151870.png

Figure 06

LIVELOCK_TEST20121118-221151972.png

Figure 07

LIVELOCK_TEST20121118-221152073.png

Figure 08

LIVELOCK_TEST20121118-221152173.png

Figure 09

LIVELOCK_TEST20121118-221152269.png

Figure 10

LIVELOCK_TEST20121118-221152378.png

Figure 11

LIVELOCK_TEST20121118-221152458.png

Figure 12

Advanced Concurrency Topic:
Runtime Deadlock Detection XXI
Treetorplus3 and jdfrbeta01
Prototype no.1 Just Lock and Unlock
Now we realease Treetorplus3 treetorplus3.jar,treetorLicesnse.txt.
We also release jdfrbeta01.jar. 'jdfr' stands for Java Dead-lock Free Runtime. The goal is to design a runtime that will handle general concurrency issues. In the future, we may extend to operating system design/implementation. Or it may not be necessarily to design or implement something new, because we have 'injection' technology. These goals are still far. By now, what are at our hands are four prototypes. So far, we are able to profile basic concurrency events. Please note these prototype will only under the very conditions we pre-set. What works is just what worked! Any above-mentioned goals are huge tasks beyond the limited ability of the author. I spent much time studying java.util.concurrent written by Prof. Doug Lea. It corrects some very critical mis-understandings of mine. Although I am able to build these prototypes using C, C++ etc, without Java, without open source, it won't be so fast. Eclipse Java IDE also provides great help speeding up the work. 'jdfr' is open source. The jar comes with the source code inside.
The first prototype is 'Just Lock and Unlock'.
How to:


You will get the images at the folder specified.

PFLB_JUST_LOCK_UNLOCK.gif

You can also try to modify this file.


Advanced Concurrency Topic:
Runtime Deadlock Detection XXII
Treetorplus3 and jdfrbeta01
Prototype no.2 Simple Blocker and Blockee
How to:


You will get the images at the folder specified.

PFLB_BLOCK_UNBLOCK_SIMPLE.gif

You can also try to modify this file.


Advanced Concurrency Topic:
Runtime Deadlock Detection XXIII
Treetorplus3 and jdfrbeta01
Prototype no.3 A More Complex Blocker and Blockee
How to:

You will get the images at the folder specified.

PROFLB_BLOKER_BLOKEE_COMLEX.gif

You can also try to modify this file.


Advanced Concurrency Topic:
Runtime Deadlock Detection XXIV
Treetorplus3 and jdfrbeta01
Prototype no.4 A Simple Dead-lock Profiled
How to:


You will get the images at the folder specified.
After the dead-lock is formed, the program will not stop unless a forced ctrl-C. The late tryer caused the dead-lock is painted by 'stop-sign' color.
If you find any errors or you want to leave other comments, please send me email.

DEAD_LOCK_VISUAL.gif


You can also try to modify this file.


PNGs:

DEAD_LOCK_VISUAL20121211-011216521.pngFigure 01

DEAD_LOCK_VISUAL20121211-011216915.pngFigure 02

DEAD_LOCK_VISUAL20121211-011217085.pngFigure 03

DEAD_LOCK_VISUAL20121211-011217215.pngFigure 04

DEAD_LOCK_VISUAL20121211-011217378.pngFigure 05

DEAD_LOCK_VISUAL20121211-011217505.pngFigure 06

DEAD_LOCK_VISUAL20121211-011217636.pngFigure 07

DEAD_LOCK_VISUAL20121211-011217779.pngFigure 08

DEAD_LOCK_VISUAL20121211-011217929.pngFigure 09

DEAD_LOCK_VISUAL20121211-011218078.pngFigure 10

Advanced Concurrency Topic:
Runtime Deadlock Detection XXV
A Bad Prototype
Here, we present a bad prototye. We also give some reasons to present it even it is bad.
How to:


You would need these two jars: and treetorplus3.jar and jdfrbadprototype01.jar.
You can study the source code inside jdfrbadprototype01.jar. You can also check out the entry point TwoLayersDeadlockImprovisedSolution.java.


Why it is bad?
Simply, it does not full-fill the purpose of the desgin or the requirement(s). In "Advanced Concurrency Topic: Runtime Deadlock Detection XIX Visualization of an Imaginary Concurrency Event" and "Advanced Concurrency Topic: Runtime Deadlock Detection XX Visualization Results of XIX", I drew a series of diagrams. We tried to conjecture a scheduler that creates a live-lock. Two threads keep yielding each other, but neither of them can acquire all the resources it needs. Neither of them can finish its job.
To build this prototype, we made an assumption. It was also made from the beginning I dived into the dead-lock detection topic. The assumption is that we would be able to read one thread's status from another thread. Thus, we can detect deadlock. Live-lock is construct-able if a thread can know what its peer thread trying to get. If it just gives up one but not all the peer needs, live-lock could happen.
From this prototype, we know this assumption is wrong. If we execute the command line given, it will create either a dead-lock or the starvation of one of the threads. A thread's status is so volatile. A running thread will be blocked, go to sleeping, or perished. A blocked thread can be unblocked just next several CPU ticks. One thing is certain if a thread had finished. We may say two threads are like two particles, can this be called 'entangling', to observe accurately will affect the behavior the object being observed. Or to say, we can describe space/status or time accurately either of them but not both of them at the same time. I am not in physics area, so I stop short here and come back to our topic.
So if we can not read another thread's status from one thread, which is a fundamental mis-understanding, are we completely wrong so we can do nothing( we may also argue that we can lock status, a thread status has read write lock etc-- nightmare of spaghetti)? In our previous discussion, we show a healthy system is a tree-like structure. When a dead-lock is formed, it becomes a cyclic graph. But once the dead-lock is formed, no threads can change their status, suppose we use a no-time-out lock(). What we did in the middle of this topic, help us properly construct the graph. When dead-lock happens, we can detect it. The profiling or detecting mission is accomplished.
Advanced Concurrency Topic:
Runtime Deadlock Detection XXVI
An Artificial Livelock
Although our attempt at XXV failed, we can still make a scheduler that follows the digram we drew.
You would need these two jars: and treetorplus3.jar and jdfr1.0.jar.

How to:


You can check out the entry point:


So, you would see the concern is no longer to create a live-lock. At the end of each thread, we did something. I hope this will provide some hint about how to deal with concurrent program that looks bizzare. In general, we should not fear live-lock. As long as the threads are alive, we will have a chance to change the resource access pattern. If a system has no hope, that is the real problem.

20130122artificial_live_lock.gif

Advanced Concurrency Topic:
Runtime Deadlock Detection XXVII
More Tested Examples
Multi-tier

201301PROF_MUTLTI_TIER.gif

How to:

Entry point:


Fast
How to:


Entry point:


Random
How to:

Entry point:


Advanced Concurrency Topic:
Runtime Deadlock Detection XXVIII
Period
So far, months have been spent upon this topic. The resources are limited, I have to put a period. We may continue on with the same topic or similiar topic.

Today, we release jdfr1.0.jar.
- it fully supports Java ReentrantLock
- it has several proto-types, quick-starts or just say examples -- in the Blog section

It will be a very useful tool to profile concurrent programming. We also have treetor treetorplus3.jar which can render about several thousands nodes of a-cyclic graph or a forest. If I got enough support, we may switch to OpenGL rendering engine and using more advanced IPC.

We corrected some mis-understandings. They are critical but finally not fatal to this project.
I am still not sure about next step. I hope there will be more people download and study what I did. It will be a great pleasure that you can achieve something with these tools. Science and technology does not rely on luck. If you find any bug or errors, please feel free to point them out. This project is done by one person, so it is convenient to control. In real life projects, we have to resolve human conflicts, legacy pacakges etc. Some time you do not even have the source code not mention how to modify them. So we can not simply put a easy or difficult label for a project.
The methods we tried or proposed, may be helpful while extending to profile database system, interprocess concurrent programming, the operating system, or for clustered computing units. Concurrent programming in some sense destroyed the von Neuman architecture, much more effort is needed for understanding or utilizing the nature of concurrency.
Advanced Concurrency Topic:
Runtime Deadlock Detection XXVII
More Tested Examples
Multi-tier

201301PROF_MUTLTI_TIER.gif

How to:

Entry point:


Fast
How to:

Entry point:


Random
How to:

Entry point:


Advanced Concurrency Topic:
Runtime Deadlock Detection XXVIII
Period
So far, months have been spent upon this topic. The resources are limited, I have to put a period. We may continue on with the same topic or similiar topic.

Today, we release jdfr1.0.jar.
- it fully supports Java ReentrantLock
- it has several proto-types, quick-starts or just say examples -- in the Blog section

It will be a very useful tool to profile concurrent programming. We also have treetor treetorplus3.jar which can render about several thousands nodes of a-cyclic graph or a forest. If I got enough support, we may switch to OpenGL rendering engine and using more advanced IPC.

We corrected some mis-understandings. They are critical but finally not fatal to this project.
I am still not sure about next step. I hope there will be more people download and study what I did. It will be a great pleasure that you can achieve something with these tools. Science and technology does not rely on luck. If you find any bug or errors, please feel free to point them out. This project is done by one person, so it is convenient to control. In real life projects, we have to resolve human conflicts, legacy pacakges etc. Some time you do not even have the source code not mention how to modify them. So we can not simply put a easy or difficult label for a project.
The methods we tried or proposed, may be helpful while extending to profile database system, interprocess concurrent programming, the operating system, or for clustered computing units. Concurrent programming in some sense destroyed the von Neuman architecture, much more effort is needed for understanding or utilizing the nature of concurrency.