Monday, October 23, 2017

Paradise ponders: dogs and C edition...

Paradise ponders: dogs and C edition...  There's a morning ritual at our house that is by now burned into the brains of our five (!) dogs.  The ritual has several parts, all of which the dogs have firmly associated with canine bliss.  The first part is the morning excursion to the back yard.  We generally let them out first thing after we get up, even before we do our morning ablutions.  The dogs all know that nothing else happens until they've gone outside and done their business.  They do that quickly, and then as soon as they see activity in our kitchen (as when we've finally really gotten up), then they clamor at the door to be let in – they know what's coming next: bananas!

With five dogs I changed from one banana to two, so they each get roughly 40% of a banana.  And they go bananas!  I peel the two bananas in the kitchen sink, which causes great excitement – especially for Ipo and Mako, both of whom are able to stick their noses over the edge of the counter and slightly into the sink.  There is much leaping and wagging and doggie excitement!  Then I take the two peeled bananas and a knife, and with my back to a kitchen wall wait for the dogs to form a semi-circle around me.  Ipo always performs one little ceremony: she darts into her crate, and then back out to the semi-circle.  Once they've all settled into place, I start slicing the banana and tossing them to a particular dog, saying their name just before I do it.  This is aimed at helping them associate their name to themselves and something good.  It works. :)

Once the bananas are gone, I (and usually Debbie) settle into our morning tea, coffee, and toast or pastry routine.  We're generally talking, reading news or email, etc. during this time.  The dogs are all watching us carefully, waiting for signs that we're finished.  They are incredibly good at detecting these signs, and you can see them winding up as the end approaches – because they know that once we're done, I'm going to feed them.  And that, of course, is the best moment of the day!

We have a small laundry room adjacent to our kitchen.  In there is a cabinet with a rollout drawer that we keep our dog food container in, with a low granite counter top above it.  In the left photo below, you can see that arrangement, caught in the middle of my filling of the bowls.  The three stainless steel bowls that are full of food are for our three youngest (Mako, Cabo, and Ipo), all of whom we feed in their crate.  So the first step for the feeding ritual is always the same: pull out the food drawer, unscrew the lid of the food container, and fill the three stainless steel bowls.  The dogs watch me on every step of this stage, making sure I'm doing it right.  The second photo shows the view behind me as I'm working: dogly inspectors hard at work.  After I fill the first three bowls, I take them (stacked up as in the photo) into the kitchen.  There I fill each bowl with warm water sufficient to cover the food (this brings out the smells in the food).  Then I take them over to the crates, stacked up again – and the three who are about to be fed dart at maximum possible speed straight into their crate.  Often there's a big crashing noise as they hit then end before turning around to await the delivery of their bowl.  Then the crunching and slurping begins. :)


After the young ones are chomping on their kibble, I return to the laundry room to fill the two big blue plastic bowls, for Miki and Race.  These two, being (much) older dogs, get less food, lest they turn into fat old men.  If anything, this makes them even more eager for their morning chow.  Miki's only demonstrations of physicality come during these moments that I'm walking toward the laundry room to fill their bowls.  He knows it's his turn, and he's very excited.  Race is just as excited, but seems to know he doesn't have to work to get his food – he just has to be patient.  So he hovers nearby, emitting little whimpers occasionally, as I fill their bowls with kibble and warm water.  Finally the big moment comes for them: the bowls are put into their stands in the laundry room, and they go to work with great enthusiasm.  Those bowls, you might note, are not smooth on the inside.  As Michelle's boy A.J. likes to say, they've got obstacle courses in them.  These bowls cured Miki and Race of a bad habit: gobbling their food down so quickly that they'd often puke it right back up.  They can't do that with these bowls, as the only way they can get most of the kibble down their gullets is to worm out the individual pieces with their tongues.  They take about twice as long to eat as the younger dogs, but the problems we used to have with their gulping eating style are all gone...

After all five dogs have finished, things are much calmer in the house.  I let them all back outside again, and then they start the serious business of doggie play.  This is their way of waiting out the clock for the morrow's morning, when the doggie ritual of joy starts all over again...

I spent a lot of the day yesterday debugging my C program, and I expect to be doing a bit more this morning.  From a very high level, debugging in C is no different than debugging in any other programming language.  At a lower level, though, it's very different than debugging in Java (where most of my recent experience is) – mainly because most of the problems I encounter are things like uninitialized variables, memory allocation goofs, and pointer errors of one sort or another.  In that respect, it's much more akin to debugging in assembly language, right on the (computer) metal.  Here's one example I debugged yesterday.  The broken code:

*count = 0;

while( TC && (*count < max) ) {
    int c = readSerialChar( fdPort, charWaitNs );
    if( c > 0 ) {
        buffer[*count] = (byte) c;
        count++;
    }
}
return *count >= max;

See the problem?  I didn't see it until I stepped through it with a debugger!  Here's the corrected code (highlighted in orange):

*count = 0;

while( TC && (*count < max) ) {
    int c = readSerialChar( fdPort, charWaitNs );
    if( c > 0 ) {
        buffer[*count] = (byte) c;
        (*count)++;
    }
}
return *count >= max;

This sort of error (referencing a pointer variable directly, instead of the object it was pointing too) just doesn't happen in Java.  There are no pointers, or so the language proponents like to claim (really, all the object instances are pointers internally, but the language does a great job of hiding that from you).

This difference in debugging is neither good nor bad, just different.  Especially, I think, for someone like me who hasn't done any “low level” debugging for a zillion years or so... :)