<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9104296995463008905</id><updated>2011-07-08T11:21:59.333-07:00</updated><category term='CLIPC'/><category term='JNI'/><category term='Array Access'/><category term='Semaphores'/><category term='IPC'/><category term='XMing'/><category term='Synchronization'/><category term='Linux'/><category term='Samba'/><category term='Eclipse'/><category term='X-Windows'/><category term='SELinux'/><category term='Gotchas'/><category term='ByteBuffer'/><category term='Shared Memory'/><category term='File Naming'/><category term='FIFOs'/><category term='MappedByteBuffer'/><title type='text'>LTSLLC Blog</title><subtitle type='html'>Postings about software development in general and Java in particular.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-5813391554837514233</id><published>2009-10-04T16:17:00.000-07:00</published><updated>2009-10-04T16:20:51.443-07:00</updated><title type='text'>Openfire Admin Login</title><content type='html'>How to change Openfire's admin login when using Windows Vista and an embedded database:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Shut down Openfire&lt;/li&gt;&lt;li&gt;&lt;b&gt;As the Windows Administrator, &lt;br /&gt;&lt;/b&gt;Edit&lt;br /&gt;&lt;br /&gt;C:\Program Files (x86)\Openfire\embedded-db\openfire.script&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Change the line that looks something like this&lt;br /&gt;&lt;br /&gt;INSERT INTO OFUSER VALUES('admin',NULL,'&amp;lt;hex string&amp;gt;', 'Administrator','admin','0','0')&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;&lt;br /&gt;INSERT INTO OFUSER VALUES('admin','&amp;lt;new password&amp;gt;',NULL, 'Administrator','admin','0','0')&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Save the file, exit the editor&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Restart Openfire&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size: large;"&gt;Here are the same instructions in a more annoying format:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Maybe this is just me but...well...I'd actually rather not deal with that alternative so I'm assuming that this is Openfire's problem problem and not mine.&lt;br /&gt;&lt;br /&gt;OK, so for the upteenth time*, I lost the admin password on my Openfire installation.&amp;nbsp; Openfire is like the most user friendly XMPP server out there...that I know of...and I know of like 2 others so this one must be really, like, user friendly.&amp;nbsp; Anyhow, so I lost my admin login...&lt;i&gt;again&lt;/i&gt;...and I tried to figure out how I could change that password without having to reinstall Openfire.&lt;br /&gt;&lt;br /&gt;This applies to the Windows installation with an embedded database.&amp;nbsp; If you are using a real operating system and a real database, you probably don't have this problem.&amp;nbsp; If you do then it's because of you...not me.** &lt;br /&gt;&lt;br /&gt;At any rate, if you're really unfortunate (read, me), then you are running on the the very &lt;i&gt;interesting&lt;/i&gt; and &lt;i&gt;very secure&lt;/i&gt; operating system that is Microsoft Vista.&amp;nbsp; In that case, you may find that Openfire is squatting in the following directory:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;C:\Program Files (x86)\Openfire&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Yes, it uses that font rather than courier.&amp;nbsp; Really.&lt;br /&gt;&lt;br /&gt;What's more, the embedded database lives in &lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;C:\Program Files (x86)\Openfire\embedded-db&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Note that Vista took out the blank in just about everywhere &lt;i&gt;except&lt;/i&gt; for the programs directory.&lt;br /&gt;&lt;br /&gt;This makes it more secure.&lt;br /&gt;&lt;br /&gt;I mean, why else would they have done it?&lt;br /&gt;&lt;br /&gt;At this point, a stand-up comic would make an observation about how they recently had a child and wait politely for the audience to applaud.&amp;nbsp; The idea is to get the audience on your side by a) pointing out that you recently had a child and b) that you have been without sleep and c) are running Microsoft Vista and d) are on the edge and e) that not applauding could very well push you over the edge and f) whatever.&lt;br /&gt;&lt;br /&gt;Now then, the embedded database does everything in memory except that it loads everything at startup.&amp;nbsp; Actually, I'm not sure if that's what it does at all, but it &lt;i&gt;looks&lt;/i&gt; that way; and, since I'm the sort of person who forgets their admin login at the drop of a hat, I'm obviously the sort of person that you should listen to.***&lt;br /&gt;&lt;br /&gt;The file&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;openfire.script&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Has the various logins and passwords for the system.&amp;nbsp; In a bold move to ensure security, the passwords are encrypted.&amp;nbsp; Or rather, there is a field for the users table that contains a field called "encryptedpassword."&amp;nbsp; There is another password called "plainpassword."&amp;nbsp; Except both fields do not contain a period in the name.&amp;nbsp; I hate punctuation.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Now I know what you're thinking: "HA HA!&amp;nbsp; I shall just change the field that says 'email' to the new password and then the system shall let me in!"&amp;nbsp; This is why I make $300 an hour and you don't.****&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;What you actually need to do is change the "plainpassword" to the new password, and then change the "encryptedpassword" to "NULL!"******.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Except it doesn't work.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;This is because the &lt;i&gt;very interesting&lt;/i&gt; and &lt;i&gt;extremely secure&lt;/i&gt; operating system, Windows Vista, will not let you save the file to that directory!&amp;nbsp; Instead you have to use the &lt;i&gt;extremely secure &lt;/i&gt;step of editing the file as the administrator.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;OK, so you do all the above and it &lt;i&gt;still&lt;/i&gt; doesn't work.&amp;nbsp;&amp;nbsp; At this point, if you are like me, you are saying &lt;i&gt;Why is this clown using italics so much*******&lt;/i&gt; In addition you would not******** think to edit this file after shutting down Openfire, since that program rewrites the startup file every time it shuts down.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;And then, only then, after all this enjoyable fun, would you be able to log onto Openfire.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;* = which is, by the way, not because of me.&lt;br /&gt;** = this has been verified by ltsllc.com.&amp;nbsp; Which is affiliated with me.&amp;nbsp; So therefore it's probably not objective.&lt;br /&gt;*** = if you believe this and have a lot of money to waste on consultants, please contact me.&lt;br /&gt;**** = if you believe or even if you don't, but you are willing to pay this amount for at least a year and you don't expect to get anything useful out of it, please contact me.*****&lt;br /&gt;***** = P.S. to the previous note, you are also required to actually &lt;i&gt;have that much money&lt;/i&gt; and &lt;i&gt;be willing to give it to me in advance&lt;/i&gt; before contacting me.&lt;br /&gt;****** = except that you leave off the exclamation point.&amp;nbsp; See, there really is a reason to pay me lots of money.&lt;br /&gt;******* = except you were probably able to spell "italics" correctly on the first try.&amp;nbsp; Teacher's pet.&lt;br /&gt;******** = see points above about giving me lots of money.&lt;br /&gt;********* = does anyone else actually read footnotes?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-5813391554837514233?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/5813391554837514233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/10/openfire-admin-login.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/5813391554837514233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/5813391554837514233'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/10/openfire-admin-login.html' title='Openfire Admin Login'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-7742035032953248644</id><published>2009-06-28T17:57:00.000-07:00</published><updated>2009-06-29T20:11:39.136-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Shared Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><category scheme='http://www.blogger.com/atom/ns#' term='FIFOs'/><title type='text'>CLIPC SMFIFOs</title><content type='html'>I posted some ideas for a new CLIPC feature that I am currently calling "shared memory FIFOs".  For those who are interested, please take a look at the posting on the SourceForge site and post any thoughts, concerns, etc.&lt;br /&gt;&lt;br /&gt;The link is:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sourceforge.net/apps/wordpress/clipc/2009/06/29/smfifos/"&gt;http://sourceforge.net/apps/wordpress/clipc/2009/06/29/smfifos/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(Note: this link previously pointed to a page that asked you for a password.  It has been updated so that it no longer does that.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-7742035032953248644?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/7742035032953248644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/06/clipc-smfifos.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7742035032953248644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7742035032953248644'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/06/clipc-smfifos.html' title='CLIPC SMFIFOs'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-7047868482918045886</id><published>2009-06-17T12:07:00.000-07:00</published><updated>2009-06-17T12:17:24.112-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><title type='text'>New CLIPC Site</title><content type='html'>I am gradually going to be moving all things CLIPC to the SourceForge site.  In particular I am hoping to create some basic documentation on how to use CLIPC and its various components to the blog associated with that project. &lt;br /&gt;&lt;br /&gt;&lt;a href="http://clipc.sourceforge.net"&gt;The CLIPC site is at http://clipc.sourceforge.net&lt;/a&gt;&lt;br /&gt;&lt;a href="https://sourceforge.net/apps/wordpress/clipc/"&gt;The CLIPC blog is at https://sourceforge.net/apps/wordpress/clipc/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-7047868482918045886?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/7047868482918045886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/06/new-clipc-site.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7047868482918045886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7047868482918045886'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/06/new-clipc-site.html' title='New CLIPC Site'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-7996643844763379299</id><published>2009-06-15T17:10:00.000-07:00</published><updated>2009-06-15T17:12:50.195-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><title type='text'>CLIPC 0.2 up on SourceForge</title><content type='html'>The new and improved version of CLIPC is &lt;a href="http://sourceforge.net/projects/clipc/"&gt;now available on SourceForge&lt;/a&gt;.  This new version includes, among other things, non-blocking FIFOs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-7996643844763379299?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/7996643844763379299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/06/clipc-02-up-on-sourceforge.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7996643844763379299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7996643844763379299'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/06/clipc-02-up-on-sourceforge.html' title='CLIPC 0.2 up on SourceForge'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-4554826721469834192</id><published>2009-05-09T16:42:00.000-07:00</published><updated>2009-05-09T16:53:13.616-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='X-Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='XMing'/><title type='text'>Xming Locks!</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;Short Story&lt;/h2&gt; Starting up the gnome session manager from within a gnome-terminal avoids the annoying "Not Responding" problem that I get when going from Vista to Linux via XMing.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;Long Story&lt;/h2&gt; Briefly, here is what I did to get it to work:  &lt;ul&gt;&lt;li&gt;&lt;a href="#no_access_control"&gt;Start Xming without access control&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#putty"&gt;SSH to the Linux system and set DISPLAY&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#gnome_terminal"&gt;Start a gnome-terminal&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#session"&gt;From within the gnome-terminal, start a gnome-session&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;h3&gt;Background&lt;/h3&gt; This is using XMing 6.9.0.31 to display something from  Fedora Core 10 (2.6.27.19-170.2.35.fc10.i686) on Vista Home Permium.  &lt;p&gt; For reasons unknown (anyone here with info, please comment), XMing seems to lock up on Vista frequently.  After as little as 10 seconds, the main window stops responding to requests. &lt;/p&gt;  &lt;p&gt; I would set up XMing using the configuration that I  &lt;a href="http://ltsllc.blogspot.com/2009/04/xming-rocks-yes-it-does.html"&gt;  outlined in a previous post.&lt;/a&gt;  &lt;/p&gt; &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyFq6ssI/AAAAAAAAADs/zmDpWDbKOBY/s1600-h/not_responding.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 257px;" src="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyFq6ssI/AAAAAAAAADs/zmDpWDbKOBY/s400/not_responding.png" alt="" id="BLOGGER_PHOTO_ID_5333974758926758594" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;i&gt;Xming after a few seconds&lt;/i&gt;&lt;/span&gt; &lt;/center&gt;  &lt;a name="no_access_control"&gt;  &lt;h3&gt;Start Xming without access control&lt;/h3&gt;&lt;/a&gt; I'm not exactly fond of this, but unfortunately I did not find a way around this.  If I do, I will post this info in a followup.&lt;br /&gt;&lt;br /&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyOObrMI/AAAAAAAAAD0/rVwgD-yOcsM/s1600-h/no_access_control.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 309px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyOObrMI/AAAAAAAAAD0/rVwgD-yOcsM/s400/no_access_control.png" alt="" id="BLOGGER_PHOTO_ID_5333974761223204034" border="0" /&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;&lt;i&gt;XLaunch dialog&lt;/i&gt;&lt;/span&gt; &lt;/center&gt;  &lt;p&gt; This results in the rather...blank Xming display: &lt;/p&gt;  &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyXMpliI/AAAAAAAAAD8/tQg_tUZyBhY/s1600-h/blank_xming.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 244px;" src="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyXMpliI/AAAAAAAAAD8/tQg_tUZyBhY/s400/blank_xming.png" alt="" id="BLOGGER_PHOTO_ID_5333974763631646242" border="0" /&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;&lt;i&gt;Blank and not very useful&lt;/i&gt;&lt;/span&gt; &lt;/center&gt;   &lt;a name="putty"&gt;&lt;h3&gt;SSH to the Linux system and set DISPLAY&lt;/h3&gt;&lt;/a&gt; Using putty or whatever, log onto the Linux system.  Note that this is using  SSH, telnet, but not with something graphical like an xterm.  &lt;p&gt; Next set the X-Windows environment variable, DISPLAY, to point back to the Vista system.  I'm sure there's some way of doing this with a script, but  I'm too lazy to figure it out. &lt;/p&gt;   &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyhCN4uI/AAAAAAAAAEE/9OZDB5eF3ic/s1600-h/setup_display.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 250px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyhCN4uI/AAAAAAAAAEE/9OZDB5eF3ic/s400/setup_display.png" alt="" id="BLOGGER_PHOTO_ID_5333974766272242402" border="0" /&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;&lt;i&gt;Setup the DISPLAY variable&lt;/i&gt;&lt;/span&gt; &lt;/center&gt;   &lt;a name="gnome_terminal"&gt;  &lt;h3&gt;Start a gnome-terminal&lt;/h3&gt;&lt;/a&gt; I expect that xterm or kdeterm or others would do just as well, but my system  only seems to have "gnome-terminal."  This should result in an unadorned, ugly,  terminal appearing on the Vista system:&lt;br /&gt;&lt;br /&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SgYVy9kS-bI/AAAAAAAAAEM/IOqnjGVgx7A/s1600-h/gnome-terminal-3.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 305px;" src="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SgYVy9kS-bI/AAAAAAAAAEM/IOqnjGVgx7A/s400/gnome-terminal-3.png" alt="" id="BLOGGER_PHOTO_ID_5333974773931375026" border="0" /&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;&lt;i&gt;Note the lack of border and resize.&lt;/i&gt;&lt;/span&gt; &lt;/center&gt;  &lt;a name="session"&gt;&lt;h3&gt;   From within the gnome-terminal, start a gnome-session&lt;/h3&gt;&lt;/a&gt; Emphasis on &lt;i&gt;&lt;b&gt;from within the gnome-terminal!&lt;/b&gt;&lt;/i&gt;  I've tried doing  this from the SSH session and it does not seem to work.  Don't ask me why... it's just Linux!  &lt;p&gt; Once again, perhaps this may work using the KDE equivalent, but this is what  I use. &lt;/p&gt;  &lt;p&gt; After starting up a session, the Xming display changes from the ugly  default to something better looking: &lt;/p&gt;   &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYWmlOU6cI/AAAAAAAAAEc/djxFbU0N8cI/s1600-h/gnome-session-2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 317px;" src="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYWmlOU6cI/AAAAAAAAAEc/djxFbU0N8cI/s400/gnome-session-2.png" alt="" id="BLOGGER_PHOTO_ID_5333975660749973954" border="0" /&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;&lt;i&gt;Note the window now has a window bar, border and the background has changed.&lt;/i&gt;&lt;/span&gt; &lt;/center&gt;  &lt;p&gt; gnome-session also spouts about a page and a half of scary-looking gibberish. The thing seems to work despite all this. &lt;/p&gt;  &lt;a name="conclusion"&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;&lt;/a&gt; Using this approach, Xming is &lt;i&gt;much&lt;/i&gt; more responsive than with the other  approaches I've tried.  It is somewhat cryptic, and various steps may not even  be necessary.  If you find other approaches that work, please post them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-4554826721469834192?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/4554826721469834192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/05/xming-locks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/4554826721469834192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/4554826721469834192'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/05/xming-locks.html' title='Xming Locks!'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_5rPFhJ6lzLg/SgYVyFq6ssI/AAAAAAAAADs/zmDpWDbKOBY/s72-c/not_responding.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-7558863835455131239</id><published>2009-04-29T19:15:00.000-07:00</published><updated>2009-04-29T19:51:22.715-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Gotchas'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='JNI'/><title type='text'>JNI/Windows Gotchas: UnsatisfiedLinkError</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Short Story&lt;/h2&gt; This post describes a solution that has worked for me when I get a an UnsatisfiedLinkError on Windows using MingW, while developing a JNI library.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Long Story&lt;/h2&gt; Java Native Interface (JNI) development on Windows is extremely annoying.  There are all kinds of land mines strewn randomly about the landscape to snare the  wary and unwary alike.  Any one of these issues can require hours of hair-tearing in order to get things to a working state.  &lt;p&gt; After dealing with enough of these, I decided to post some of the solutions I've  found in order to save others from premature baldness.  For today's entertainment,  I have selected the infameous UnsatisfiedLinkError. &lt;/p&gt;  &lt;a name="java_library_path"&gt; &lt;h3&gt;  java.lang.UnsatisfiedLinkError: no &lt;library&gt; found in java.library.path &lt;/library&gt;&lt;/h3&gt; &lt;/a&gt; This is caused by not having the DLL that contains your C/C++ code in the path that  Java is using to find it.  If you have this problem, try this:  &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=9104296995463008905&amp;amp;postID=7558863835455131239#java_library_path_step_01"&gt;Bring up the properties for the   project containing the native declarations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=9104296995463008905&amp;amp;postID=7558863835455131239#java_library_path_step_02"&gt;From the properties dialog, bring   up the build path for the project.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=9104296995463008905&amp;amp;postID=7558863835455131239#java_library_path_step_03"&gt;From the build path properties,   edit the native libraries location for the project.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=9104296995463008905&amp;amp;postID=7558863835455131239#java_library_path_step_04"&gt;From the resulting dialog, select   the folder where your DLLs live &lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;a name="java_library_path_step_01"&gt; &lt;h3&gt;Bring up the properties for the project containing the native declarations&lt;/h3&gt; &lt;/a&gt; For example:  &lt;p&gt; &lt;/p&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfkKuDK8sXI/AAAAAAAAADE/CW1tlWeg0RE/s1600-h/usle04_02.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 347px; height: 400px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfkKuDK8sXI/AAAAAAAAADE/CW1tlWeg0RE/s400/usle04_02.png" alt="" id="BLOGGER_PHOTO_ID_5330303420211179890" border="0" /&gt;&lt;/a&gt; &lt;/center&gt;   &lt;p&gt; For the CLIPC project, this is clipc-java.  You can be sure by selecting the Java  project that contains the .java files with declarations like this one: &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SfkNmoF3okI/AAAAAAAAADU/Kp5vHxkgR_g/s1600-h/usle05.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 141px;" src="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SfkNmoF3okI/AAAAAAAAADU/Kp5vHxkgR_g/s400/usle05.png" alt="" id="BLOGGER_PHOTO_ID_5330306591217918530" border="0" /&gt;&lt;/a&gt; &lt;/center&gt;    &lt;a name="java_library_path_step_02"&gt;  &lt;h3&gt;From the properties dialog, bring up the build path for the   project.&lt;/h3&gt; &lt;/a&gt; For example:  &lt;p&gt; &lt;/p&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkKt_l8mkI/AAAAAAAAAC0/7vYQWs2wwQo/s1600-h/usle03.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkKthWheUI/AAAAAAAAACs/lMV1XTcdMto/s1600-h/usle02.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 326px;" src="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkKthWheUI/AAAAAAAAACs/lMV1XTcdMto/s400/usle02.png" alt="" id="BLOGGER_PHOTO_ID_5330303411132922178" border="0" /&gt;&lt;/a&gt; &lt;/center&gt; &lt;/center&gt;    &lt;a name="java_library_path_step_03"&gt;  &lt;h3&gt;From the build path properties, edit the native libraries location for   the project&lt;/h3&gt; &lt;/a&gt; For example:  &lt;p&gt; &lt;/p&gt;&lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkKt_l8mkI/AAAAAAAAAC0/7vYQWs2wwQo/s1600-h/usle03.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 326px;" src="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkKt_l8mkI/AAAAAAAAAC0/7vYQWs2wwQo/s400/usle03.png" alt="" id="BLOGGER_PHOTO_ID_5330303419250678338" border="0" /&gt;&lt;/a&gt; &lt;/center&gt;    &lt;a name="java_library_path_step_04"&gt;  &lt;h3&gt;From the resulting dialog, select the folder where your DLLs live&lt;/h3&gt; &lt;/a&gt; For example, this tells Eclipse to look in the workspace:  &lt;p&gt; &lt;/p&gt;&lt;center&gt;  &lt;center&gt;  &lt;center&gt;  &lt;center&gt;   &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfkKt_v5fjI/AAAAAAAAAC8/04kgsFL-mCY/s1600-h/usle04_01.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 176px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfkKt_v5fjI/AAAAAAAAAC8/04kgsFL-mCY/s400/usle04_01.png" alt="" id="BLOGGER_PHOTO_ID_5330303419292417586" border="0" /&gt;&lt;/a&gt; &lt;/center&gt;  &lt;/center&gt; &lt;/center&gt; &lt;/center&gt; &lt;/center&gt;   &lt;p&gt; Then this tells Eclipse where to look for the DLL: &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;&lt;center&gt;  &lt;center&gt;   &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkOqaXihaI/AAAAAAAAADc/1LMeTtX-P2c/s1600-h/usle04_02.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 347px; height: 400px;" src="http://3.bp.blogspot.com/_5rPFhJ6lzLg/SfkOqaXihaI/AAAAAAAAADc/1LMeTtX-P2c/s400/usle04_02.png" alt="" id="BLOGGER_PHOTO_ID_5330307755765040546" border="0" /&gt;&lt;/a&gt; &lt;/center&gt;  &lt;/center&gt; &lt;/center&gt;    &lt;h2&gt;Conclusion&lt;/h2&gt; If you have an UnsatisfiedLinkError, you may need to tell Eclipse where your DLLs live.  This post gives a step-by-step on how to do that.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-7558863835455131239?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/7558863835455131239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/jniwindows-gotchas-unsatisfiedlinkerror.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7558863835455131239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/7558863835455131239'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/jniwindows-gotchas-unsatisfiedlinkerror.html' title='JNI/Windows Gotchas: UnsatisfiedLinkError'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfkKuDK8sXI/AAAAAAAAADE/CW1tlWeg0RE/s72-c/usle04_02.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-1989229590047618416</id><published>2009-04-25T08:00:00.000-07:00</published><updated>2009-04-29T19:43:56.016-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='X-Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='XMing'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>XMing Rocks (yes, it does)!</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfJvjHtzw4I/AAAAAAAAABM/DWPFaiS-JEw/s1600-h/xming.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 310px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfJvjHtzw4I/AAAAAAAAABM/DWPFaiS-JEw/s400/xming.jpg" alt="" id="BLOGGER_PHOTO_ID_5328443958290006914" border="0" /&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:85%;"&gt;The gnome windows manager desktop on Fedora 10&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;Short Story&lt;/h2&gt; If you need to develop on Windows and Linux, XMing will allow you to run programs  on a Linux box and display them on a Windows machine.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;Long Story&lt;/h2&gt; As the chief architect, engineer, and only developer on the  &lt;a href="http://ltsllc.blogspot.com/2001/04/faq.html"&gt;CLIPC&lt;/a&gt;  project, I need to be able to develop on Linux and Windows.  Developing on  Linux has been something of a chore up until now, because I had to  either "rlogin" onto the machine, and give up any GUI capabilities, or physically sit in front of the system.   &lt;h3&gt;Cygwin-X&lt;/h3&gt; I've been trying to get a better setup for a couple of days and then I hit  on the idea of using the ability of X-Windows to forward a display to another machine.  One of the (many) problems that I encountered was getting an X-Windows server to actually run on Windows.  &lt;p&gt; At first I tried to use Cygwin-X, the x-windows that comes with &lt;a href="http://cygwin.com/"&gt;Cygwin&lt;/a&gt;, but I found it difficult to use.  Any time I run a program and it seems to do nothing, I start getting testy.  Specifically, I selected  &lt;/p&gt;&lt;pre&gt; Start&gt;Cyginw-X&gt;Start XWin Server&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; After a bit of puttering about, I recalled running "startx" from the keyboard.  I  tried that from a Cygwin session and was "rewarded" with this: &lt;/p&gt;  &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SfJvWMbZb1I/AAAAAAAAAA8/5n3kFCq4IBQ/s1600-h/cygwin-x.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 310px;" src="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SfJvWMbZb1I/AAAAAAAAAA8/5n3kFCq4IBQ/s400/cygwin-x.jpg" alt="" id="BLOGGER_PHOTO_ID_5328443736216661842" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;Ugh...this actually makes Windows look good!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/center&gt;  &lt;p&gt; At this, I felt like I had been thrown into a time warp back to the 90's when  you could peg the CPU of a machine running X by just bringing up a menu. &lt;/p&gt;  &lt;p&gt; Mind you, I have tremendous respect and gratitude towards the folks who maintain  cygwin.  But there are limits. &lt;/p&gt;  &lt;h3&gt;Enter XMing&lt;/h3&gt; After glaring at Cygwin-X for a bit, I tried looking for something else.  Google, after much prodding and use of &lt;i&gt;something-or-other:&lt;/i&gt; directives turned up  &lt;a href="http://sourceforge.net/projects/xming"&gt;XMing.&lt;/a&gt;  &lt;p&gt; I've been using &lt;a href="http://mingw.sourceforge.net/"&gt;MinGW&lt;/a&gt; for quite a while in general, and for the Windows portion of CLIPC in particular, so I am reasonably comfortable with things MING.  I downloaded it and installed it in under 10min.  Perhaps under 5min. &lt;/p&gt;  &lt;p&gt; With most things Linux-like I expect stuff to take at least a weekend, so this was a very nice surprise. &lt;/p&gt;  &lt;p&gt; At first I got the same, ugly X-Windows starting stuff, but with a little bit of reading, I determined how to fire up the gnome window manager.  The way to do this is to specify "gnome-terminal" as the "start program" that you get from running XLaunch. &lt;/p&gt;  &lt;p&gt; In the interest of being more helpful, here is what I used for the values in  the XLaunch config screens:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SfJvnIg4qeI/AAAAAAAAABU/FdFbG9Yyr3w/s1600-h/xming-config1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 312px;" src="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SfJvnIg4qeI/AAAAAAAAABU/FdFbG9Yyr3w/s400/xming-config1.jpg" alt="" id="BLOGGER_PHOTO_ID_5328444027223714274" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SfJvqXoXw1I/AAAAAAAAABc/9px9h8qTREs/s1600-h/xming-config2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 312px;" src="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SfJvqXoXw1I/AAAAAAAAABc/9px9h8qTREs/s400/xming-config2.jpg" alt="" id="BLOGGER_PHOTO_ID_5328444082821251922" border="0" /&gt;&lt;/a&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfJvyDY_1sI/AAAAAAAAABs/N46nS2FckmQ/s1600-h/xming-config3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 312px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfJvyDY_1sI/AAAAAAAAABs/N46nS2FckmQ/s400/xming-config3.jpg" alt="" id="BLOGGER_PHOTO_ID_5328444214827013826" border="0" /&gt;&lt;/a&gt;  &lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SfJv1hRb5pI/AAAAAAAAAB0/BeuvPH8tSIY/s1600-h/xming-config4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 312px;" src="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SfJv1hRb5pI/AAAAAAAAAB0/BeuvPH8tSIY/s400/xming-config4.jpg" alt="" id="BLOGGER_PHOTO_ID_5328444274387969682" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt; For me the most important aspect is that it can run Eclipse.  I want to have some vague confidence that my stuff will compile and run on the Linux version. &lt;/p&gt;  &lt;center&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SfJvdAT1hgI/AAAAAAAAABE/n13R9bC10Hg/s1600-h/eclipse-workspace.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 310px;" src="http://2.bp.blogspot.com/_5rPFhJ6lzLg/SfJvdAT1hgI/AAAAAAAAABE/n13R9bC10Hg/s400/eclipse-workspace.jpg" alt="" id="BLOGGER_PHOTO_ID_5328443853222807042" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;Eclipse running on Linux and forwarded to Windows&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/center&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt; MingX is a user-friendly solution for those who want to forward X-Windows from  a Linux box to a Windows box.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-1989229590047618416?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/1989229590047618416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/xming-rocks-yes-it-does.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/1989229590047618416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/1989229590047618416'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/xming-rocks-yes-it-does.html' title='XMing Rocks (yes, it does)!'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_5rPFhJ6lzLg/SfJvjHtzw4I/AAAAAAAAABM/DWPFaiS-JEw/s72-c/xming.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-6972749751127193</id><published>2009-04-23T07:03:00.000-07:00</published><updated>2009-04-23T07:07:36.080-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><category scheme='http://www.blogger.com/atom/ns#' term='File Naming'/><category scheme='http://www.blogger.com/atom/ns#' term='Semaphores'/><title type='text'>CLIPC File Naming</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;NOTE&lt;/h2&gt; The source code shown here may not be up on SourceForge until 4/23/2009 (Friday). This is due to some last minute problems found with the Linux code.  I'll provide more information as it becomes available.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Short Story&lt;/h2&gt; CLIPC uses file names to identify IPC resources.  If two processes use the same file name for a Semaphore, they get connected to the same Semaphore.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Long Story&lt;/h2&gt; You can find the &lt;a href="http://sourceforge.net/projects/clipc"&gt;source code  and examples for CLIPC on SourceForge.&lt;/a&gt;     &lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;Naming: The Orphan Child of IPC&lt;/h3&gt; It seems to me that a great deal of effort has gone into ensuring that various IPC schemes are "correct" or that their waiting schemes are "fair," while somewhat less effort has gone into ensuring that they are easy to use. In particular, how do two processes that have no prior association connect in order to communicate?     &lt;p&gt; Different platforms use different schemes for dealing with this problem.  For semaphores, Windows has a "namespace" set aside for Semaphores and a bunch of other objects.  In Linux there are several approaches.  One of them is to use a restricted name space, another is to use integer values to identify the Semaphore. &lt;/p&gt;  &lt;h3&gt;File Names: a Ubiquitous Concept Across Platforms&lt;/h3&gt; A lot of effort during the design and evolution of Java to make file naming across platforms easier.  For example, the path "/what/ever/one" will work on both Linux and Windows.  &lt;p&gt; CLIPC builds on that strength in order to solve the naming problem for some  IPC mechanisms.   &lt;/p&gt;  &lt;p&gt; In the case of Semaphores, CLIPC uses a file name to identify which Semaphore a client wants to use.  If two processes use the same file name when creating a Semaphore, the two processes will end up connected together through that semaphore. &lt;/p&gt;  &lt;p&gt; A nice side-effect of using file names to identify resources is that it solves the problem of who can use the resource.  For example, if a client does not have permission to read a file associated with a semaphore, then they cannot access the associated semaphore. &lt;/p&gt;  &lt;h3&gt;Semaphore File Naming in CLIPC&lt;/h3&gt; In CLIPC, a client must specify a file name in order to connect to a Semphore. Here is an example where the file name is specified when the constructor is called:  &lt;code&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;Semaphore s = new Semaphore("/mysem");&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; Here is an example where the file name is specified when the Semaphore is connected to the underlying system resource: &lt;/p&gt;  &lt;code&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;Semaphore s = new Semaphore();&lt;br /&gt;...&lt;br /&gt;s.connect("/mysem");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt; CLIPC uses the name of the file to store a value that, when used in the  underlying system call, will identify a Semaphore to the platform.  If such a  file exists at the time when the connection occurs, CLIPC will use the contents of the existing file instead of creating a new file. &lt;/p&gt;  &lt;h3&gt;File Creation and Race Conditions&lt;/h3&gt; Such a scheme has an inherent race condition in that if two processes decide to create the file at the same time, it is possible that both with think they were successful, yet each is using a different underlying identifier.  &lt;p&gt; CLIPC handles this problem by using a two step process: &lt;/p&gt;  &lt;ul&gt;&lt;li&gt;Create a temporary file and populate it with an identifier&lt;/li&gt;&lt;li&gt;Rename the temp file to the desired file name &lt;/li&gt;&lt;/ul&gt;  &lt;p&gt; For windows and Linux, renaming can be an atomic operation.  In particular, it can be made to fail if the desired name is already being used.  This ensures that in the case where two processes try to create the file at the same time, only one will succeed.   &lt;/p&gt;   &lt;h3&gt;Conclusion&lt;/h3&gt; CLIPC uses file names for handling the issue of identifying which IPC Semaphore a client wants to use.  File names are ubiuitous across platforms that Java supports, making them convenient for use as IPC "names."  CLIPC uses files with semaphores to store the underlying platform ID for a semaphore.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-6972749751127193?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/6972749751127193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/note-source-code-shown-here-may-not-be.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/6972749751127193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/6972749751127193'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/note-source-code-shown-here-may-not-be.html' title='CLIPC File Naming'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-5815242293910905086</id><published>2009-04-22T11:57:00.000-07:00</published><updated>2009-04-22T13:23:01.389-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><category scheme='http://www.blogger.com/atom/ns#' term='Semaphores'/><category scheme='http://www.blogger.com/atom/ns#' term='IPC'/><title type='text'>CLIPC Semaphores in Action</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Short Story&lt;/h2&gt; How the CLIPC Semaphore class can be used to solve the lost update problem.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Long Story&lt;/h2&gt; You can find the &lt;a href="http://sourceforge.net/projects/clipc"&gt;source code for CLIPC on SourceForge.&lt;/a&gt;  The example that I'm showing here can also be found on SourceForge.   &lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;The Lost Update: How Not to Run a Bank&lt;/h3&gt; Here is some code that implements the bank application  &lt;a href="http://ltsllc.blogspot.com/2009/04/clipc-semaphores-synchronization.html"&gt; described in the previous blog entry on semaphores.&lt;/a&gt;   &lt;p&gt; An account is implemented as a text file that contains the balance of the account.   Clients use the following process: &lt;/p&gt;  &lt;ol&gt;&lt;li&gt;Pause for a random period of time&lt;/li&gt;&lt;li&gt;Read the account balance from the file&lt;/li&gt;&lt;li&gt;Pause for a random period of time&lt;/li&gt;&lt;li&gt;Calculate the new balance/decision the withdraw&lt;/li&gt;&lt;li&gt;Write out the new balance to the file&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt; The program randomly decides the amount to deposit/withdraw, with the limitation  that it cannot withdraw more money than exists in the account. &lt;/p&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;   public void run(File file, Random r) throws Exception&lt;br /&gt;   {&lt;br /&gt;       ThreadUtils.sleep(r.nextInt(2000));&lt;br /&gt;       int balance = readBalance(file);&lt;br /&gt;       sleep(r.nextInt(4000));&lt;br /&gt;       int amount = generateTransactionAmount(r, balance);&lt;br /&gt;       printMessage(balance, amount);&lt;br /&gt;       balance = balance + amount;&lt;br /&gt;       writeBalance(file, balance);&lt;br /&gt;   }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;   &lt;p&gt; Here is a screenshot of the app not working quite as desired:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5rPFhJ6lzLg/Se9pWZjVpwI/AAAAAAAAAAc/eagHilOClX4/s1600-h/lost_no_sems.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 377px;" src="http://4.bp.blogspot.com/_5rPFhJ6lzLg/Se9pWZjVpwI/AAAAAAAAAAc/eagHilOClX4/s400/lost_no_sems.jpg" alt="" id="BLOGGER_PHOTO_ID_5327592717739730690" border="0" /&gt;&lt;/a&gt;    &lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;With Semaphores: the Lost Update Found!&lt;/h3&gt; By adding a semaphore, the lost update problem can be avoided.  The previous process needs to be modified a little bit:  &lt;ol&gt;&lt;li&gt;Lock the account (reserve the semaphore)&lt;/li&gt;&lt;li&gt;Read the account balance from the file&lt;/li&gt;&lt;li&gt;Pause for a random period of time&lt;/li&gt;&lt;li&gt;Calculate the new balance/decision the withdraw&lt;/li&gt;&lt;li&gt;Write out the new balance to the file&lt;/li&gt;&lt;li&gt;Unlock the account (release the semaphore)&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt; The modified code: &lt;/p&gt;  &lt;code&gt;&lt;pre&gt;&lt;br /&gt;   public void run(Semaphore sem, File file, Random r) throws Exception&lt;br /&gt;   {&lt;br /&gt;       ThreadUtils.sleep(r.nextInt(2000));&lt;br /&gt;       &lt;b&gt;sem.decrement();&lt;/b&gt;&lt;br /&gt;       int balance = readBalance(file);&lt;br /&gt;       sleep(r.nextInt(4000));&lt;br /&gt;       int amount = generateTransactionAmount(r, balance);&lt;br /&gt;       printMessage(balance, amount);&lt;br /&gt;       balance = balance + amount;&lt;br /&gt;       writeBalance(file, balance);&lt;br /&gt;       &lt;b&gt;sem.increment();&lt;/b&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;   &lt;p&gt; The output from the revised sample program:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5rPFhJ6lzLg/Se9ponAFSdI/AAAAAAAAAAk/5zdJeXGDv80/s1600-h/lost_with_sems.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 377px;" src="http://1.bp.blogspot.com/_5rPFhJ6lzLg/Se9ponAFSdI/AAAAAAAAAAk/5zdJeXGDv80/s400/lost_with_sems.jpg" alt="" id="BLOGGER_PHOTO_ID_5327593030587599314" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt; The code to connect to the semaphore or to create it if it does not already exist  is: &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt; Semaphore(&lt;i&gt;fileName&lt;/i&gt;);&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; The file is an actual file that is used to allow clients to connect to the same  semaphore.  I'll explain more in the next post. &lt;/p&gt;  &lt;p&gt; This code creates a binary semaphore.  To create a semaphore that can have a max value of "n" use this call: &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt; Semaphore(&lt;i&gt;fileName&lt;/i&gt;, &lt;i&gt;max value&lt;/i&gt;);&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; For this example, a binary semaphore was used.  A command line argument passed the  name of the semaphore file.  &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt; sem = new Semaphore(argv[1]);&lt;br /&gt;&lt;/pre&gt;   &lt;h3&gt;Conclusion&lt;/h3&gt; This posting contained a quick example of how to solve the "Lost Update" problem  &lt;a href="http://ltsllc.blogspot.com/2009/04/clipc-semaphores-synchronization.html"&gt;  described in a previous post&lt;/a&gt; using a binary semaphore from the CLIPC  library.  The sample code  &lt;a href="http://sourceforge.net/projects/clipc"&gt;can be obtained from  SourceForge, along with the rest of the CLIPC code.&lt;/a&gt;   &lt;p&gt; This example uses file naming for semaphores without really explaining what  file naming is or what it is for.  In the next exciting chapter of the ongoing  CLIPC saga, I will explain how that works. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-5815242293910905086?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/5815242293910905086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/clipc-semaphores-in-action.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/5815242293910905086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/5815242293910905086'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/clipc-semaphores-in-action.html' title='CLIPC Semaphores in Action'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_5rPFhJ6lzLg/Se9pWZjVpwI/AAAAAAAAAAc/eagHilOClX4/s72-c/lost_no_sems.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-8424532892702028903</id><published>2009-04-19T06:58:00.000-07:00</published><updated>2009-04-19T07:16:18.810-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Synchronization'/><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><category scheme='http://www.blogger.com/atom/ns#' term='Semaphores'/><title type='text'>CLIPC Semaphores: Synchronization</title><content type='html'>&lt;h2&gt;The Short Story&lt;/h2&gt;&lt;br /&gt;A semaphore is a mechanism for synchronizing two processes. Synchronization is needed when two separate processes can interfere with each other.  Semaphores work via decrement (reserve) and increment (release) operations.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The Long Story Part I: What is Synchronization?&lt;/h2&gt; Semaphores are a method of inter-process communication (IPC) for synchronizing multiple processes.    &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The Lost Update&lt;/h3&gt; &lt;p&gt; Suppose you had a bank application that managed deposits and withdraws to one account.  Here is a simple pseudo program for doing this: &lt;/p&gt;  &lt;ol&gt;&lt;li&gt;Read the account balance&lt;/li&gt;&lt;li&gt;Calculate the new balance/decision the withdraw&lt;/li&gt;&lt;li&gt;Write out the new balance&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt; Here is what the program, balance, etc. might look like if we wanted to deposit $40: &lt;/p&gt;  &lt;table border="1"&gt; &lt;tbody&gt;&lt;tr&gt;  &lt;td&gt;&lt;b&gt;Action&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Amount&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Balance&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;Read balance&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Calculate new balance&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Write updated balance&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt; This works fine so long as there is only one process working with the account,  but what if two processes are trying to handle operations on the account?  Suppose one of them is trying to deposit $40, while the other wants to withdraw $70.   Here is how it might look: &lt;/p&gt;  &lt;table border="1"&gt; &lt;tbody&gt;&lt;tr&gt;  &lt;td&gt;&lt;b&gt;Process&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Action&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Amount&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Balance&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Read balance&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Read balance&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Calculate new balance&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Write updated balance&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Calculate new balance&lt;/td&gt;&lt;td&gt;30&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Write updated balance&lt;/td&gt;&lt;td&gt;30&lt;/td&gt;&lt;td&gt;30&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt; The $40 deposit has been lost because of concurrent update issues. &lt;/p&gt;  &lt;h3&gt;Fix for the Lost Update Found!&lt;/h3&gt; &lt;p&gt; Suppose the pseudo program were changed so that it took other processes into account: &lt;/p&gt;  &lt;ol&gt;&lt;li&gt;Lock the account&lt;/li&gt;&lt;li&gt;Read the account balance&lt;/li&gt;&lt;li&gt;Calculate the new balance/decision the withdraw&lt;/li&gt;&lt;li&gt;Write out the new balance&lt;/li&gt;&lt;li&gt;Unlock the account&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt; Now if the same problematic situation were to arise, here is how things might play out: &lt;/p&gt;  &lt;table border="1"&gt; &lt;tbody&gt;&lt;tr&gt;  &lt;td&gt;&lt;b&gt;Process&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Action&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Amount&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;&lt;b&gt;Balance&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Lock account&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Read balance&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Lock account&lt;/td&gt;&lt;td&gt;Operation blocks&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Calculate new balance&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Write updated balance&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Deposit 40&lt;/td&gt;&lt;td&gt;Unlock account&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Lock account&lt;/td&gt;&lt;td&gt;operation completes&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Read balance&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Calculate new balance&lt;/td&gt;&lt;td&gt;70&lt;/td&gt;&lt;td&gt;140&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Write updated balance&lt;/td&gt;&lt;td&gt;70&lt;/td&gt;&lt;td&gt;70&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;&lt;td&gt;Withdraw 70&lt;/td&gt;&lt;td&gt;Unlock account&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;70&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt; By putting in the locks, the deposit is no longer lost. &lt;/p&gt;  &lt;h3&gt;Binary Semaphores as Exclusive Locks&lt;/h3&gt; &lt;p&gt; In this situation, a binary semaphore could implement the "lock/unlock" operations used to synchronize access to the account.   &lt;/p&gt;  &lt;p&gt; A binary semaphore allows two states: reserved and available.  If a process tries to reserve a semaphore that has already been reserved, as when the withraw process tries to perform its operation when the deposit processes has locked the account, the requesting process will block and go into a waiting/sleep state. &lt;/p&gt;  &lt;p&gt; When the process that has reserved the semaphore releases it, the operating system  chooses a process that is waiting for the semaphore and unblocks it.  The above scenario depicts just such a situation. &lt;/p&gt;  &lt;p&gt; The underlying mechanism for a semaphore is an integer value.  When a process wants to reserve the semaphore, they &lt;b&gt;decrement&lt;/b&gt; the semaphore's value. When the process is done with the resource, it releases the semaphore by  &lt;b&gt;incrementing&lt;/b&gt; its value. &lt;/p&gt;  &lt;p&gt; With a binary semaphore, the object can have a value of 0 or 1.  Therefore, if the  semaphore has a value of 1 and a processes wants to reserve it by decrementing the semaphore, the semaphore's value becomes 0.  When done with the resource,  the process increments the semaphore and the value becomes 1.   &lt;/p&gt;  &lt;p&gt; If a process tries to decrement a semaphore whose value is already 0, the operation blocks until the other process that "owns" the semaphore increments it again. &lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt; That was a quick introduction to synchronization and semaphores.  In future posts, I will go over how semaphores are used in CLIPC.&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-8424532892702028903?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/8424532892702028903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/clipc-semaphores-synchronization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/8424532892702028903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/8424532892702028903'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/clipc-semaphores-synchronization.html' title='CLIPC Semaphores: Synchronization'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-2355432736416853430</id><published>2009-04-16T17:13:00.001-07:00</published><updated>2009-04-16T18:47:53.061-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLIPC'/><category scheme='http://www.blogger.com/atom/ns#' term='IPC'/><category scheme='http://www.blogger.com/atom/ns#' term='JNI'/><title type='text'>Introducing CLIPC</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Short Story&lt;/h2&gt; &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt; is a new open-source java library for IPC.  It provides new IPC primitives like semaphores and shared queues, and it makes existing primitives like shared memory easier to use.  CLIPC currently supports the Windows and Linux platforms.   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Long Story&lt;/h2&gt; &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt; is the com.lts.ipc library that I wrote because I could not find a Java library that did some Inter-Process Communications (IPC) functions  that I was interested in. &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt; has been the topic of several talks that I have given recently at the  &lt;a href="http://www.boulderjug.org/"&gt;Boulder Java Users Group (BJUG)&lt;/a&gt; and the &lt;a href="http://www.denveropensource.org/meetingminutes"&gt;Denver Open Source  Users Group (DOSUG).&lt;/a&gt;  &lt;p&gt; Over the next couple of weeks, I am hoping to create some blog entries about  &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt; and some of the trials and tribulations I went through to write the library. This will be of interest to people who are interested in IPC and also those  are are interested in the Java Native Interface (JNI). &lt;/p&gt;  &lt;p&gt; &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt; makes use of JNI because Java does not support certain IPC concepts like Semaphores and FIFOs.  This requires the use of JNI to perform the required system calls and whatnot through C, a language that the two platforms that &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt; currently supports uses. &lt;/p&gt;  &lt;p&gt; Another aspect of &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt;/JNI is that it requires the creation of a consistent interface across multiple platforms.  Both Windows and Linux support First-In, First-Out messaging (FIFOs), but the similarities pretty much end there. &lt;/p&gt;  &lt;p&gt; For example, on Windows there are Named Pipes.  These are always bi-directionaly and function in a lot of ways like very fast TCP/IP connections.  Named pipes are represented with files in a special  directory. &lt;/p&gt;  &lt;p&gt; Linux also supports FIFOs, but on that platform they are uni-directional.  They appear to be files on the file system in that there are no naming requirements and they can appear anywhere that regular files can.  Linux FIFOs require no special system calls in order to connect to, though they do require special calls to create. &lt;/p&gt;  &lt;p&gt; How do you reconcile these differences in order to create a uniform interface to FIFOs?  Should they really be more like the named pipes of Windows and allow bi-directional data flow or should they be uni-directional? &lt;/p&gt;  &lt;p&gt; I don't know if I made the best decisions possible for &lt;a href="http://sourceforge.net/projects/clipc/"&gt;CLIPC&lt;/a&gt;, but I can talk  about why I made the decisions that I did.  This will be the topic of future blog entries. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-2355432736416853430?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/2355432736416853430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/introducing-clipc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/2355432736416853430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/2355432736416853430'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/introducing-clipc.html' title='Introducing CLIPC'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-6113958922195816938</id><published>2009-04-12T05:42:00.000-07:00</published><updated>2009-04-12T09:00:05.856-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Samba'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='SELinux'/><title type='text'>Linux, Samba, NTFS and Selinux</title><content type='html'>&lt;h2&gt;The Short Story&lt;/h2&gt; I had a problem where windows kept giving me an "access denied" error when I tried to access a file share from Linux.  Using the following commands allowed it to work:  &lt;br /&gt;&lt;code&gt;&lt;pre&gt; &lt;br /&gt;    semanage fcontext -a -t samba_share_t "&amp;lt;share&amp;gt;"&lt;br /&gt;    setsebool -P samba_share_fusefs 1&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;   &lt;br /&gt;&lt;h2&gt;The Long Story&lt;/h2&gt; After converting a Windows system to a Linux system (Fedora 10), I wanted to be able to use it as a file server via Samba and furthermore to be able to access my old hard drive.    &lt;p&gt; The initial problem was that I could create the share, but I could not use it  via windows.  Whenever I tried I received a "permission denied" error.  I tried  making the share world readable, etc. but this did not help. &lt;/p&gt;  &lt;p&gt; The "secure linux troubleshooter" --- SETroubleShooter, which I found from the  application&gt;system tools menu, had a good suggestion for the solution to the  problem:  &lt;code&gt; &lt;/code&gt;&lt;/p&gt;&lt;pre&gt;    semanage fcontext -a -t samba_share_t "&amp;lt;share&amp;gt;"&lt;br /&gt;&lt;/share&gt;&lt;/pre&gt;   &lt;p&gt; This allowed Samba to share the part of the disk that I had set aside for the file  server.  All well and good.  Then I tried to share the old system disk. &lt;/p&gt;  &lt;p&gt; This required some special mounting options because it was formatted with NTFS.   Here is the entry from /etc/mtab: &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt;     /dev/sda2 /export/whatever fuseblk rw,allow_other,blksize=4096 0 0&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; The system was able to mount the volume and I could ls around it etc., but trying to share it via Samba failed.  I couldn't figure out what was going on until I tried disabling SELinux entirely via the following: &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt;    echo 0 &gt; /selinux/enforce&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; I then tried the share and it worked.  I then reenabled SELinux: &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt;    echo 1 &gt; /selinux/enforce&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; At this point I felt like turning off SELinux and leaving it off, but some additional looking around on the web turned up this command: &lt;/p&gt;  &lt;code&gt; &lt;/code&gt;&lt;pre&gt;    setsebool -P samba_share_fusefs 1&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt; For whatever reason, SELinux needs to be told separately that it should let Samba share NTFS file systems as well as regular file systems. &lt;/p&gt;  &lt;p&gt; All this may sound nice and easy, but it took hours of hair-tearing and glaring at the monitor.  I found that SELinux/Samba interactions are not anywhere near as well documented as regular Samba problems. &lt;/p&gt;  &lt;p&gt; I found the following pages to be useful in troubleshooting this problem: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://our.obor.us/node/2032"&gt;http://our.obor.us/node/2032&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.mjmwired.net/resources/mjm-fedora-f10.html#samba"&gt;   http://www.mjmwired.net/resources/mjm-fedora-f10.html#samba  &lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-6113958922195816938?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/6113958922195816938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/04/linux-samba-ntfs-and-selinux.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/6113958922195816938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/6113958922195816938'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/04/linux-samba-ntfs-and-selinux.html' title='Linux, Samba, NTFS and Selinux'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-3772104298744218350</id><published>2009-03-13T11:45:00.001-07:00</published><updated>2009-03-13T19:02:02.716-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Array Access'/><category scheme='http://www.blogger.com/atom/ns#' term='ByteBuffer'/><category scheme='http://www.blogger.com/atom/ns#' term='JNI'/><title type='text'>ByteBuffer is Fast Enough</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The Short Story&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;ByteBuffer.get/put is fast enough&lt;/li&gt;&lt;li&gt;Concentrate data into chunks of 256+ bytes&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;The Long Story&lt;/h2&gt;&lt;a href="http://ltsllc.blogspot.com/2009/03/bytebuffer-jni-and-array.html"&gt;Following up my posting&lt;/a&gt; about how ByteBuffer.get/put appeared to be about 3 times slower than simple array accessing, I did some testing.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;ByteBuffer is Slow?  Not so Fast!&lt;/h3&gt;&lt;br /&gt;ByteBuffer.put(byte[] b) is actually faster than using the array operator (e.g., b[0], b[1], etc.) ; &lt;span style="font-style: italic;"&gt;for array sizes larger than 256 bytes.&lt;/span&gt; If you are moving around data with a ByteBuffer in chunks of less than 256 bytes, arrays may be faster.  ByteBuffer can be much faster as the size of the array approaches and exceeds 4kB.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SbqrqhkmYfI/AAAAAAAAAAU/5P1jlBJ4fW0/s1600-h/size_band.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 273px;" src="http://1.bp.blogspot.com/_5rPFhJ6lzLg/SbqrqhkmYfI/AAAAAAAAAAU/5P1jlBJ4fW0/s400/size_band.jpg" alt="" id="BLOGGER_PHOTO_ID_5312747457491657202" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;i&gt;ByteBuffer becomes as fast as regular arrays at a buffer size of about 256 bytes&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;The Java array operator appears to have a bandwidth of 300MB/sec.  This is the amount of time that it takes to read 1 byte from an array location and then write a value to the location.  Put another way, the turn-around time for Java arrays is less than 5 nsec.&lt;br /&gt;&lt;p&gt;&lt;/p&gt;Performing the same operations with ByteBuffer.get/put at 1 byte per operation, the bandwidth could be as low as 7MB/sec; giving a turn-around time of less than 150 nsec.  At first glance this is a huge difference: it suggests that ByteBuffer is 30 times slower than array access!&lt;br /&gt;&lt;br /&gt;The bandwidth of ByteBuffer increases &lt;i&gt;exponentially&lt;/i&gt; with the buffer size. When you hit about 256 bytes, array access and ByteBuffer are equivalent.  ByteBuffer's performance continues to increase until you hit about 4KB in size --- at which point you are looking at over 1GB/sec.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Size Matters&lt;/h3&gt;&lt;p&gt;The moral of the story is: try to concentrate your data.  If you can put all the commonly accessed stuff into a block of 256+ bytes, access will be efficient.  If you are in the situation where your data is small and scattered, things may get dicey.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Time Will Tell&lt;/h3&gt;&lt;br /&gt;Another important consideration is time.  Ask yourself "do I really need a 5nsec response time?"  The CPU cache is around 1 nsec and main memory is around 10 nsec.  If you really need to turn one or two operations around that fast, you are pushing the performance boundaries of the platform.&lt;br /&gt;&lt;p&gt;If the answer is "yes, it really needs to be that fast," then it may be better to do this sort of thing entirely in JNI.  That way Java index boundary checking can be avoided.  Since we are talking about time scales where that could be a factor, it could make a difference.&lt;br /&gt;&lt;br /&gt;If the answer is "no, 1 usec is easily fast enough," then ByteBuffer is probably the way to go.  It will be much simpler and when you are trying to debug something, you can be much more confident that the problem is not in how shared memory is being read from or written to.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Your Mileage Will Vary&lt;/h3&gt;&lt;br /&gt;If you try the tests I performed on your own system, you will get different results.  The nature of the tests makes them very sensitive to things like cache size, front-side bus speed, etc.  The values I mention here like array access times of 300MB/sec are approximate.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Test Code&lt;/h3&gt;&lt;br /&gt;&lt;a href="http://ltsllc.com/downloads/002/smbtest.jar"&gt;For those who are interested, you can find the test code here.&lt;/a&gt;  The source is included in the executable JAR.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-3772104298744218350?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/3772104298744218350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/03/bytebuffer-is-fast-enough.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/3772104298744218350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/3772104298744218350'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/03/bytebuffer-is-fast-enough.html' title='ByteBuffer is Fast Enough'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_5rPFhJ6lzLg/SbqrqhkmYfI/AAAAAAAAAAU/5P1jlBJ4fW0/s72-c/size_band.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-1652802172299515775</id><published>2009-03-12T08:03:00.000-07:00</published><updated>2009-03-12T07:11:23.765-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Shared Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='ByteBuffer'/><category scheme='http://www.blogger.com/atom/ns#' term='JNI'/><title type='text'>JRE and Shared Memory Overhead</title><content type='html'>Shared memory access in Java appears to be about 3 times slower than it could be.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://ltsllc.blogspot.com/2009/03/shared-memory-using-mappedbytebuffer.html"&gt;In another post&lt;/a&gt;, I mentioned that ByteBuffer and its related classes provide a way for Java developers to access shared memory without having to resort to JNI.  The problems come in when you try to perform operations on that segment.&lt;br /&gt;&lt;br /&gt;One approach is to get a reference to an array of bytes that represents the data in the segment and then use the regular array syntax to access the data.  The ByteBuffer.array() method appears to be the the way to do this, but unfortunately it does work.&lt;br /&gt;&lt;br /&gt;Here is an example of what I mean:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// DOES NOT WORK!!&lt;br /&gt;MappedByteBuffer mbb;&lt;br /&gt;// code to initialize mbb omitted&lt;br /&gt;byte[] ba = mbb.array(); // throws UnsupportedOperationException&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After looking around a bit, I came to the conclusion that this was the intention of the original developers --- if you want to mess with the data in the segment, then you are supposed to use ByteBuffer.get/put.&lt;br /&gt;&lt;br /&gt;This would be fine if get/put were about the same cost as using a straight byte array, but they appear to be 2 to 3 times slower.  &lt;a href="http://ltsllc.com/downloads/001/BufferTest.java"&gt;Here is a simple program that highlights the issue I'm running into.&lt;/a&gt;  The basic difference is that one version uses:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;b1 = bb.get(0);&lt;br /&gt;bb.put(0, b2);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And the other that uses&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;b1 = bb[0];&lt;br /&gt;bb[0] = b2;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The program performs these operations millions of times and then prints out the time (in milliseconds) they took to run.  An example output:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Using get/put: 11578&lt;br /&gt;Using array access: 3234&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;One thing this shows is that I really need to upgrade my system.&lt;br /&gt;&lt;br /&gt;The basic point is that using get/put is a lot slower than using simple arrays.  A program that reads and writes a lot of data in shared memory would be a lot faster if it could simply use an array rather than get/put.&lt;br /&gt;&lt;br /&gt;Is there a way around this?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-1652802172299515775?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/1652802172299515775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/03/bytebuffer-jni-and-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/1652802172299515775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/1652802172299515775'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/03/bytebuffer-jni-and-array.html' title='JRE and Shared Memory Overhead'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-1794540385272041938</id><published>2009-03-11T12:39:00.000-07:00</published><updated>2009-03-11T15:38:54.088-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Shared Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='MappedByteBuffer'/><title type='text'>Shared Memory Using MappedByteBuffer</title><content type='html'>Java developers can access shared memory using the NIO class MappedByteBuffer.  Here is an example:&lt;br /&gt;&lt;pre&gt;RandomAccessFile rac = new RandomAccessFile("&amp;lt;some file name&amp;gt;", "rw");&lt;br /&gt;FileChannel channel = rac.getChannel();&lt;br /&gt;MappedByteBuffer buf = channel.map(MapMode.READ_WRITE, 0, 1024);&lt;br /&gt;&lt;/pre&gt;This will create a shared memory segment with the name of the file passed to RandomAccessFile.  The segment will start out with the contents of that file, if it exists.  If the file does not exist, then it will be created.&lt;br /&gt;&lt;br /&gt;The segment can be changed or read using the get/put methods defined by the ByteBuffer class.  A different Java process that uses the same set of of calls will get the same shared memory: if they change their instance you will see the changes and vice versa.  What's more, this also applies to non-java processes that use the same file name and memory mapped system calls.&lt;br /&gt;&lt;br /&gt;I have tried this on Windows and Linux and I have also taken a look at the implementation code on java.net  It appears that both platforms are using memory mapped files.&lt;br /&gt;&lt;br /&gt;As an aside, "memory mapped files" are an approach to using shared memory that appear to have originated with Unix.  Unix tries to make most things look like files, so representing shared memory that way is pretty consistent with the Unix philosophy.&lt;br /&gt;&lt;br /&gt;For those who are interested, &lt;a href="http://ltsllc.com/downloads/001/MBBExample.java"&gt;here is a more complete example.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-1794540385272041938?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/1794540385272041938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/03/shared-memory-using-mappedbytebuffer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/1794540385272041938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/1794540385272041938'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/03/shared-memory-using-mappedbytebuffer.html' title='Shared Memory Using MappedByteBuffer'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-8762190245677695289</id><published>2009-03-11T12:00:00.000-07:00</published><updated>2009-03-11T14:01:46.467-07:00</updated><title type='text'>Welcome!</title><content type='html'>This site is about software development in general, with an emphasis on Java.  It contains insights, discoveries, etc. that I have encountered while performing development on various projects.&lt;br /&gt;&lt;br /&gt;"LTSLLC" is short for "Long Term Software, LLC." the consulting company that I created.  I find blogger to be more convenient than Wordpress, otherwise I would host this blog off &lt;a href="http://ltsllc.com"&gt;the main ltsllc site&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-8762190245677695289?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/8762190245677695289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2009/03/welcome.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/8762190245677695289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/8762190245677695289'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2009/03/welcome.html' title='Welcome!'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9104296995463008905.post-6195546136303894724</id><published>2001-04-23T07:28:00.000-07:00</published><updated>2009-04-29T19:44:56.956-07:00</updated><title type='text'>FAQ</title><content type='html'>&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;What is CLIPC?&lt;/h2&gt;&lt;br /&gt;CLIPC is a an open-source Java library for interprocess communications that runs on Windows and Linux.  &lt;a href="http://www.blogger.com/sourceforge.net/projects/clipc"&gt;You can find the source code for the library as well as examples on SourceForge.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;What does "CLIPC" stand for?&lt;/h2&gt;&lt;br /&gt;CLIPC stands for &lt;b&gt;c&lt;/b&gt;om.&lt;b&gt;l&lt;/b&gt;ts.&lt;b&gt;ipc&lt;/b&gt;, the package name of the library.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;What is ltsllc?&lt;/h2&gt;&lt;br /&gt;That's short for &lt;a href="http://ltsllc.com"&gt;Long Term Software, LLC.&lt;/a&gt; the consulting company that the author (Clark N. Hobbie), owns.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;Does CLIPC run on the Mac?&lt;/h2&gt;&lt;br /&gt;It may, but I have not tried it.  If you try CLIPC on the Mac please send me an&lt;br /&gt;email and let me know how if and how it works.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9104296995463008905-6195546136303894724?l=ltsllc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ltsllc.blogspot.com/feeds/6195546136303894724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ltsllc.blogspot.com/2001/04/faq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/6195546136303894724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9104296995463008905/posts/default/6195546136303894724'/><link rel='alternate' type='text/html' href='http://ltsllc.blogspot.com/2001/04/faq.html' title='FAQ'/><author><name>ltsllc</name><uri>http://www.blogger.com/profile/00868160782380846825</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
