SimVTK release 0.2.3

Another alpha release of SimVTK is ready, and can be downloaded from the SimVTK site at Queen’s University. SimVTK is a visual programming environment for VTK inside of Matlab’s Simulink. This release adds support for Mac OS X.

I had my work cut out for me in getting VTK to work inside Matlab on OS X. Matlab uses four GUI toolkits (Java, Qt, Cocoa, and X11) and uses 24 independent threads. The Simulink thread (the one in which my VTK code is running) uses X11. But VTK is using Cocoa, and each Cocoa window that VTK creates responds to mouse/keyboard events from the main Matlab application thread. The result: every time I clicked in the window, VTK code would be called from the wrong thread. Boom. The solution was to write a "proxy" Cocoa window for VTK that queues the events, so that the Simulink/VTK thread doesn’t have deal with the events until it is good and ready.

SimVTK Partial Pipeline

MacBook quick sleep

After I sold my old laptop and bought a MacBook Pro, I was constantly annoyed at how long it took to go to sleep.  When I close the lid, that usually means I'm about to toss my Mac in my bag and go… but the fact that the hard drive keeps spinning for 20 seconds makes me hesitant to do the whole "toss it in the bag" thing.  Why did it take so long for Mr. Sandman to arrive?  Was my MacBook busy counting electric sheep?

Well, actually it was busy saving its RAM to the hard drive.  Which seems silly, because it keeps the RAM powered while it sleeps.  It only saves the RAM to disk because Apple is concerned that you might leave your laptop in sleep mode for so long that it runs out of power, forcing it to read the RAM back from disk when it powers back up again.  Thank you for your concern, Apple, but what if a faster sleep is more important to me than saving the RAM to disk?

Apple doesn’t provide any sleep vs. hibernation control in its preferences, but this page says how to change hibernation modes on the command line. And it’s dirt simple!

  • sudo pmset -a hibernatemode 0

The above command makes my MacBook go to sleep instantaneously when I close the lid.  I can grab it and go, without worrying about jarring the hard drive. And I only have to run this command once, not every time I put my Mac to sleep.

The "hibernatemode" actually has several settings, for which I have created aliases in my .bash_profile:

  • alias hibernatefast="sudo pmset -a hibernatemode 0"
  • alias hibernatefull="sudo pmset -a hibernatemode 5"
  • alias hibernatesafe="sudo pmset -a hibernatemode 7"

Here, "hibernatefast" is the immediate sleep, the way that I like best; "hibernatefull" is the true hibernate mode that saves RAM to disk and turns off the power, which is what I need when boarding an airplane; "hibernatesafe" is the Apple default combined sleep/hibernate mode.

First day of Spring?

Not quite… but it certainly felt like it.  The temperature was 6 Celsius, with more of the same expected during the week.   I took the opportunity and did my "long 10" run for the first time this year.  The "long 10" is actually 11km, hence the name.

Note that the grass is not as green as in this photo.  There's still lots of snow.

Running Route 3b