Posted by Enea Team on Mon, Mar 01, 2010 @ 12:46 AM
by Ulrik Svensson
Threads are difficult. In every multi-threaded project I've been involved in, I've seen issues with deadlocks and data races. Getting it right tends to be a real challenge even for experienced developers.
After seeing these kinds of issues over and over again I started thinking about what can be done to avoid them or at least how to find them while testing. But deadlocks are difficult to catch with conventional testing and trying to verify all possible thread interleavings is usually impossible.
I was searching for existing deadlock related test tools but all I found was papers and academic proof-of-concept code, nothing that could be used for real-world testing. So I decided to invent such a testing tool myself... and it became JCarder.
JCarder is a tool that can find potential deadlocks in concurrent multi-threaded Java programs. It can analyze a program execution and tell whether a deadlock might have occurred if the threads had been scheduled differently. That is, deadlock problems can be found without triggering actual deadlocks while running the program.
Here is a simplified overview of what happens when analyzing a program with JCarder:
- First, JCarder instruments the program's byte code so that all lock operations are logged to disk.
- Next, the program continues execution as usual while logging information about its use of locks.
- Finally, when the program has finished execution, JCarder analyzes the logged information to find deadlock problems.
JCarder was initially developed by me and a colleague as an internal testing tool used by Enea, but after Enea decided to release JCarder as open source, we started to receive external contributions and patches from an evolving open source community. Recently, we added support for more advanced filters in order to improve the analysis accuracy. Those patches will be included in the next release.
Documentation, source code and binaries are available here: http://www.jcarder.org
A new release of JCarder is planned soon.
Posted by Enea Android Team on Mon, Dec 21, 2009 @ 09:58 AM
If you follow the instructions on http://source.android.com/using-eclipse you will only have a Java project and will only see the C/C++ project files as 2:nd class citizens without any indexing. I will propose a another solution that will combine the ideas from http://lorinc.blogspot.com/2006/10/how-to-mix-java-and-c-code-in-singe.html.
1. Copy the already available Java setup
|
$ cd $ cp development/ide/eclipse/.classpath . # You might need to make the copy writable (describe on android.com) $ chmod u+w .classpath |
2. From Eclipse create a new C++ project File -> New -> Other, select C/C++ -> C++ Project give it a project name and uncheck "Use default location"
and give it the path to your directory (often called the mydroid dir)
Select Project Type: "Makefile project" -> "Empty Project", let the "-- Other Toolchain" be selected and press "Finish"
3. Add in Java to the same project
Close Eclipse as you will edit a file it holds open and will overwrite otherwise Now a /.project file has been created open it in a text editor and add the following:
|
< buildCommand > < name > org.eclipse.jdt.core.javabuilder < /name > < arguments > < /arguments > < /buildCommand >
|
and
|
< nature > org.eclipse.jdt.core.javanature< /nature> |
as described here:
|
< ?xml version="1.0" encoding="UTF-8"? >
< projectdescription >
< name > android zoom2 < /name >
< comment > < /comment >
< projects >
< /projects >
< buildspec >
------------------------------- below is added
< buildCommand >
< name > org.eclipse.jdt.core.javabuilder < /name >
< arguments >
< /arguments >
< /buildCommand >
------------------------------- end of the added stuff
< buildcommand >
< name > org.eclipse.cdt.managedbuilder.core.genmakebuilder < /name >
< triggers > clean,full,incremental, < /triggers >
...
< /buildCommand >
< /buildSpec >
< natures >
< nature > org.eclipse.cdt.core.cnature < /nature >
< nature > org.eclipse.cdt.core.ccnature < /nature >
< nature > org.eclipse.cdt.managedbuilder.core.managedBuildNature < /nature >
< nature > org.eclipse.cdt.managedbuilder.core.ScannerConfigNature < /nature >
------------------------------- below is added
< nature > org.eclipse.jdt.core.javanature < /nature >
------------------------------- end of the added stuff
< /natures >
...
|
Now start eclipse again, now the Java classes are available in "Project Explorer" view and C/C++ files in "C/C++ Projects" view.
One problem remain when you build it will use "make all" and that will not work and need to be changed to "make" this can be done if you right-click on the project and select "Properties"
In the "Properties" window select "C/C++ Build" and click on the "Behaviour" tab and remove "all" from all the places where available.
I still used the java heap enlargement in eclipse.ini from the first link by changing the numbers in eclipse.ini to the numbers below:
|
-Xms128m -Xmx512m -XX:MaxPermSize=256m
|
The standard eclipse from Ubuntu 9.10 (installed from synaptic) uses this file /usr/lib/eclipse/eclipse.ini you need to be root to edit it e.g.
|
$ sudo gedit /usr/lib/eclipse/eclipse.ini |
/Zingo
Enea Whitepaper

The emergence of Android paves the way for new opportunities for the world's mobile phone manufacturers. Learn More.
Posted by Enea Android Team on Thu, Dec 03, 2009 @ 03:44 PM
Currently there is an issue with building the Android Open Source project on Ubuntu 9.10 Karmic Koala, or more specific with the Java 5 support. Java 5 was obsoleted by Sun on October 30 2009 and is not part of the Ubuntu 9.10 distribution. However there is still a need to use Java 5 for building Android since Java6 is not yet supported. There are two methods to get Java5 working on Ubuntu 9.10.
Method 1 - download and install from Sun
This method will let you install the Java5 JDK in a separate directory and add it to the path.
Download the Java5 JDK for Linux from http://java.sun.com/javase/downloads/5u21/jdk
This is a binary file that you should save to a suitable location like ~/tools
In order to make i executable chmod the file as
|
$ chmod 777 jdk-1_5_0_21-linux-i586.bin |
and run it
|
$ ./jdk-1_5_0_21-linux-i586.bin |
This will install the jdk to the current directory.
To use the JDK5 tools you need to add it first in the path before building the Android Open Source Project
|
$ export PATH=~/tools/jdk1.5.0_21/bin |
This allows you to remove the JDK5 from the path when not building Android and use the standard Java settings instead.
Method 2 - use the Ubuntu 9.04 repositories to get Java5
This method adds the Jaunty repositories and installs Java5 as the default java setting in the system. Open the sources file (/etc/apt/sources.list) for editing, as root
|
$ sudo gedit /etc/apt/sources.list |
and add:
|
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse |
save the file and close gedit. Next sync your sources by running
and install
|
$ sudo apt-get install sun-java5-jdk |
To set the system to use Java 5 you need to update your java alternatives by running
|
$ sudo update-alternatives --config java |
Choose java-1.5.0-sun and you should be done.
Hopefully the Android Open Source Project will build with Java 6 shortly but the above solutions should get you going with platform work on Ubuntu 9.10.
Enea Whitepaper

The emergence of Android paves the way for new opportunities for the world's mobile phone manufacturers. Learn More.