Home > Uncategorized > Final tests of thread problem. Preparing for 0.9

Final tests of thread problem. Preparing for 0.9

Jearduino (the Java GUI frontend to Searduino) is using JNI to load the Searduino (in practice the Arduino Simulator Engine). When doing this two techniques are in use:

Jearduino loads a dynamic library (dlopen), finds a symbol (dlsym) and then starts a new thread (pthread_create) using the symbol found. When the user requests the thread to stop calls to pthread_cancel and to dlclose are made (looks a bit different in git right now, so this refers to my (Henrik’s) local git repo.

Since the user (rightfully) expects the simulator to execute freshly built code rather than the code before the build the same amount of call to dlclose as to dlopen must be made. Why? – dlopen keeps a reference count and if the ref count is not zero it does not load the file but reuse the previously loaded file. Uh oh – so the user thinks  (I would at least) think that the new code is run but it isn’t. So we have written some code to make sure the latest code is actually loaded.

Ok, but what is the problem? ….get on with it you stupid bastard!!

Problem is that the pthread_cancel and the dlclose seemed to occasionally crash the program when occurring to closely in time. So a couple of sleep (usleep) has been added after the call to pthread_cancel. We all hate adding sleep but in this case it does not do any harm to the user – only to use as hackers. It seems to work though, so we’re keeping it. Will try to find a real solution – with no sleeps – later on.

So right now, one laptop is running tests since some hours ago. The tests are loading/running/closing code all the time… and so far 2249 runs with no crashes (compared to 1-2 runs before a crash before)….. will run the tests all night.

Yeah, some words about preparing. We’ve added quite a few features to make Searduino (in practice Jearduino) more user friendly. Once these tests pass it’s time to release 0.9 and reestablish contact with the nice Debian people since we think Searduino is good enough to put in there now.


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: