Showing posts with label women in technology. Show all posts
Showing posts with label women in technology. Show all posts

Saturday, August 22, 2015

Margaret Hamilton: 1 New Horizons: 0

A bit more on Pluto, from a compugeek perspective if not a full-on web perspective ...

The New Horizons flyby was not completely without incident.  Shortly before the flyby itself, the craft went into "safe mode", contact was lost for a little over an hour and a small amount of scientific data was lost.  The underlying problem was "a hard-to-detect timing flaw in the spacecraft command sequence".  This quite likely means what's known in the biz as a "race condition", where two operations are going on at the same time, the software behaves incorrectly if the wrong one finishes first and the developers didn't realize it mattered.

Later investigation concluded that the problem happened when "The computer was tasked with receiving a large command load at the same time it was engaged in compressing previous science data."  This means that the CPU would have been both heavily loaded and multitasking, making it more likely that various "multithreading issues" such as race conditions would be exposed.

Now, before I go on, let me emphasize that bugs like this are notoriously easy to introduce by accident and notoriously hard to find if they do creep in, even though there are a number of well-known tools and techniques for finding them and keeping them out in the first place.

The incident does not in any way indicate that the developers involved can't code.  Far from it.  New Horizons made it through a ten-year, five billion kilometer journey, arriving within 72 seconds of the expected time, and was able to beam back spectacularly detailed images.  That speaks for itself.  It's particularly significant that the onboard computers were able to recover from the error condition instead of presenting the ground crew with an interplanetary Blue Screen of Death.  More on that in a bit.

Still ...

It's July 20, 1969.  The Apollo 11 lunar lander is three minutes from landing on the Moon when several alarms go off.  According to a later recounting by the leader of the team involved
Due to an error in the checklist manual, the rendezvous radar switch was placed in the wrong position. This caused it to send erroneous signals to the computer. The result was that the computer was being asked to perform all of its normal functions for landing while receiving an extra load of spurious data which used up 15% of its time.
This is a serious issue.  If the computer can't function, the landing has to be aborted.  However,
The computer (or rather the software in it) was smart enough to recognize that it was being asked to perform more tasks than it should be performing. It then sent out an alarm, which meant to the astronaut, I'm overloaded with more tasks than I should be doing at this time and I'm going to keep only the more important tasks; i.e., the ones needed for landing ... Actually, the computer was programmed to do more than recognize error conditions. A complete set of recovery programs was incorporated into the software. The software's action, in this case, was to eliminate lower priority tasks and re-establish the more important ones.
This is awesome.  Since "awesome" is generally taken to mean "kinda cool" these days, I'll reiterate: The proper response to engineering on this level is awe.  Let me try to explain why.

Depending on where you start counting, modern computing was a decade or two old at the time.  The onboard computer had "approximately 64Kbyte of memory and operated at 0.043MHz".  Today, you can buy a system literally a million times faster and with a million times more memory for a few hundred dollars.

While 64K is tiny by today's standards, it still leaves plenty of room for sophisticated code, which is exactly what was in there.  It does, however, mean that every byte and every machine cycle counts, and for that reason among others the code itself was written in assembler (hand-translated from a language called MAC and put on punch cards for loading).  Assembler is as low-level as it gets, short of putting in raw numbers, flipping switches or fiddling with the wiring by hand.

Here's a printout of that code if you're curious.  The dark bands are from printing out the listing on green-and-white-striped fanfold paper with a line printer such as used to be common at computer centers around the world.  The stripes were there to help the eye follow the 132-character lines.  Good times.  But I digress.

Just in case writing in assembler with an eye towards extremely tight code isn't enough, the software is asynchronous.   What does that mean?  There are two basic ways to structure a program such as this one that has to deal with input from a variety of sources simultaneously: the synchronous approach and the asynchronous approach.

Synchronous code essentially does one thing at a time.  If it's reading temperature and acceleration (or whatever), it will first read one input, say temperature from the temperature sensor, then read acceleration from the accelerometer (or whatever).  If it's asking some part of the engine to rotate 5 degrees, it sends the command to the engine part, then waits for confirmation that the part really did turn.  For example, it might read the position sensor for that part over and over until it reads five degrees different, or raise an alarm if doesn't get the right reading after a certain number of tries.

Code like this is easy to reason about and easy to read.  You can tell immediately that, say, it's an error if you try to move something and its position doesn't reach the desired value after a given number of tries.  However, it's no way to run a spaceship.  For example, suppose you need to be monitoring temperature continuously and raise a critical alarm if it gets outside its acceptable range.  You can't do that if you're busy reading the position sensor.

This is why high-performance, robust systems tend to be asynchronous.  In an asynchronous system, commands can be sent and data can arrive at any time.  There will generally be a number of event handlers, each for a given type of event.  The temperature event handler might record the temperature somewhere and then check to make sure it's in range.

If it's not, it will want to raise an alarm.  Suppose the alarm is a beep every five seconds.  In the asynchronous world, that means creating a timer to trigger events every five seconds, and creating an event handler that sends a beep command to the beeper when the timer fires (or, you can set a "one-shot" timer and have the handler create a new one-shot timer after it sends the beep command).

While all this is going on, other sensors will be triggering events.  In between "the temperature sensor just reported X" and "the timer for your beeper just went off", the system might get events like "the accelerometer just reported Y" and "the position sensor for such-and-such-part just read Z".

To move an engine part in this setup, you need to send it a command to move, and also create a handler for the position sensor's event.  That handler has to include a counter to remember how many position readings have come in since the command to move, along with the position the part is supposed to get to (or better, a time limit and the expected position).

A system like this is very flexible and doesn't spend time "blocked" waiting for things to happen, but it's also harder to read and reason about, since things can happen in any order and the logic is spread across a number of handlers, which can come and go depending on what the system is doing.

And then, on top of all this, the system has code to detect and recover from error conditions, not just in the ship it's controlling but in its own operation.  Do-it-yourself brain surgery, in other words.


I report my occupation as "software engineer" for tax purposes and such, but that's on a good day.  Most of us spend most of our time coding, that is, writing detailed instructions for machines to carry out.  True software engineering means designing a robust and efficient system to solve a practical problem.  The term was coined by Margaret Hamilton, the architect of the Apollo 11 control systems quoted above and a pioneer in the design of asynchronous systems.  As the story of the lunar landing demonstrates, she and her team set a high bar for later work.

New Horizons ran into essentially the same sort of problem that Apollo 11 did, but handled it less robustly (going to "safe mode" and then recovering, as opposed to automatically re-prioritizing), all building on techniques that Hamilton and her team helped develop, and using vastly more powerful equipment and development tools based on decades of collective experience.  So, with all due respect to the New Horizons team, I'd have to say Apollo 11 wins that one.

Saturday, February 9, 2013

Hedwig and the Mobile Web

I had no idea of this until I ran across it in a Sporcle quiz:  Actress Hedy Lamarr, best known for her Hollywood roles in the 40s and 50s, and inspiration for Anne Hathaway's interpretation of Catwoman in The Dark Knight Rises, was also co-holder of a patent for "spectrum hopping" technology that eventually came to be used in WiFi, Bluetooth and CDMA.  The actual names on the patent are Hedy Kiesler Markey (Lamarr's legal name at the time) and avant-garde composer George Anthiel, a neighbor of hers who developed a means of controlling multiple player pianos.

This doesn't seem to be the first patent for such technology.  Earlier work by Otto Blackwell et. al. uses essentially the same idea.  Both use multiple frequencies, and both use a shared key to determine how to shift between frequencies.  The main difference appears to be that Blackwell uses telegraph tape as a keying mechanism while Lamarr and Antheil use player piano rolls.  However, there is little doubt that Lamarr's contributions to the invention were real and that the invention is significant.

It's interesting that both patents are presented as secret communication systems, as someone listening on only one frequency would only get part of the message.  However, it doesn't seem like it would take long for an enemy to hit on the idea of listening on more than one frequency and combining the signals.  So maybe I'm missing something [if power consumption isn't an issue, you could fill all the bands with padding -- anything that statistically looked like the real signal -- which would make the combined signal much less useful].  Today we use spread spectrum technology to increase bandwidth or decrease "power flux density" -- which I assume means about what it says.

It's also worth noting that Lamarr and Antheil didn't benefit significantly from their invention, which was not used in practice until after the patent had expired.  Lamarr did receive stock in a wireless technology company two years before her death, but it's not clear whether that came to anything.  Having made and spent millions over the course of her career, Lamarr spent much of her later years broke, and was twice arrested for shoplifting.

Thursday, April 29, 2010

Steampunk heaven

This one's another not-particularly-on-the-web item, though you can, of course, learn more about it on the web.

Over a hundred and fifty years ago, Charles Babbage designed his Difference Engine (actually, he designed it twice, the second design requiring many fewer moving parts). Less than a decade ago, it was finally built. One can be seen at the Computing History Museum in Mountain View, CA, at least until its owner finishes reinforcing his living room floor to accommodate it (hey, you can never have too many five-ton Victorian computing machines in the house).

I remember reading about the difference engine many years ago. The wisdom at the time was that it could not have been built to acceptable tolerances with the technology of the day, or if it could have been, it would have required too much force to operate.

Both of these notions have been disproved, and in fact two working examples have been built, using modern numerically-controlled milling machines, but with carefully-introduced errors to mimic the imprecision of the time (not as much as you might think -- the Victorians knew a bit about machining). With some training and practice, and with the aid of a 4:1 reduction not in the original plans, a person of average physique can literally crank the thing up and watch it produce values of a seventh-degree polynomial to thirty-one digits.

It's something to see. Forget about retro PC keyboards, this is the real deal.

Of course, the real fun would be in cranking up a Babbage Analytical Engine, but alas, the design for that one is not complete enough to implement. Not that that stopped Ada Lovelace from hacking it anyway.

Thursday, January 17, 2008

Hacking the ENIAC

On the way home today I heard a piece on Jean Bartik, nee Jennings, one of the original programmers of the ENIAC (along with Kay McNulty, Betty Snyder, Marlyn Wescoff, Fran Bilas and Ruth Lichterman).

In those days, they called programmers "computers". Before computers could use computers, they had to use calculators, slide rules and good old-fashioned pencil and paper. From that point of view the ENIAC was a major advance. Working by hand with a desk calculator, a computer needed about 40 hours for a single trajectory. Here's how Bartik describes the demonstration she and Snyder put together at the expense of much midnight oil
The trajectory ran faster than it took the missle to trace the trajectory. We printed out the trajectory and gave copies to the attendees. It was fabulous. Everyone couldn't believe their eyes. They turned off the lights in the computer room and the attendees could see the accumulators computing the numbers (the tips of the tubes were visible through holes in the front panels of the ENIAC). It set the standard for years to come when a computer was working. Hollywood used the front panels of the ENIAC as the model.
(The full transcript of the chat this is taken from, part of Nasa's Female Frontiers program for elementary school girls, can be found here).

The ENIAC was a bear to program.
It was a parallel machine where we had to essentially build a central processor using program trays, digit trays, accumulators, multiplier, divider/square rooter, function tables, master programmer and I/O devices.
Bartik and her co-workers did this by flipping switches and fiddling with cables. A facility for executing (very short) stored programs was cut from the original design but later retrofitted. This was well before the first work on assembler language. Think about that next time you complain about your IDE!

Getting the thing to do anything at all, much less perform complex computations orders of magnitude faster than previously possible, is an impressive accomplishment and definitely a neat hack.

Note: Wikipedia's article on ENIAC lists the programmers by the names they used at the time. Their individual articles are listed under the names they use (or used) later in life. I've tagged this post under those names. The full list is:
  • Jean Bartik, nee Betty Jean Jennings ("Jean")
  • Kathleen Antonelli, nee Kathleen Rita McNulty ("Kay")
  • Betty Holberton, nee Frances Elizabeth Snyder ("Betty")
  • Marlyn Meltzer, nee Marlyn Wescoff
  • Frances Spence, nee Frances Bilas ("Fran")
  • Ruth Teitelbaum, nee Ruth Lichterman

Thursday, August 30, 2007

A notable web site

If you ever need some random bits, say for a password or other magic number, there's always John Walker's HotBits generator. Nestled somewhere in the hills of Switzerland it uses a (moderately) radioactive source (in a shielded location in the basement) to generate truly random bits.

There are, of course, other ways of getting high-quality random bits, including some that aren't radioactive -- LavaRnd comes to mind. HotBits is one of the older ones on the web and so has a certain charm and hack value to it.

Even if you don't need any random bits today, Walker's fourmilab site is worth visiting on its own merits. Walker was a founder of Autodesk, makers of, among other things, the hugely successful AutoCAD, which Walker co-authored. Some of the other highlights, in no particular order:
  • The Autodesk File, chronicling the early years of a startup from the PC boom (yes, there were booms before the internet boom). This is a personal pick. Autodesk crushed a PC-CAD startup I was involved with very early in my career. Eventually, it even bought out one of the remaining pieces. The Autodesk File helped me understand how this all happened, but it should also be of general interest. The more things change ...
  • Ada Augusta, Countess of Lovelace's translation and extensive commentary Sketch of the Analytical Engine. That would be Babbage's analytical engine and that would be the Ada they named the programming language after.
  • A bunch of interesting astronomy and space pages, including an earth and moon viewer and an applet for plotting orbits around a black hole or neutron star (in case you ever get the chance to visit).
  • Essays on a variety of topics whether geekly, business-related, some of each or neither.
  • There's even an online diet planner. Bon apetit!