Showing posts with label Software Design. Show all posts
Showing posts with label Software Design. Show all posts

Sunday, 7 November 2010

Software design matters #2: The Apollo 11 Moon landing

Kick-started by John F Kennedy's legendary speech, the Apollo space programme was the incredible story of the efforts of over 400,000 people, all aligned towards achieving the goal of landing a man on the moon. We always remember the massive Saturn rockets (still the most powerful space rockets ever produced) and the skill and dedication of the Apollo astronauts who piloted these machines. Yet at the pivotal moment of the first moon landing on the Apollo 11 mission, it was ingenious software design that allowed the systems to cope with the unexpected and continue to function.

On the 20th July 1969, as the lunar lander descended towards the surface, Armstrong and Aldrin had left the rendezvous radar switched on. This was smart astronaut thinking - it meant they could abort the landing and quickly reacquire the orbiting command module if something went wrong. The radar was generating data and sending it to the guidance computer as a steady stream of interrupts. Normally this would be fine, but during this critical part of the mission the guidance computer was maxed out trying to manage navigation and the descent engine.

Unable to cope with it's tasks, the computer system overloaded and issued a 1202 program alarm. This flashed up on the astronauts display and a warning buzzer sounded in the cabin, no doubt significantly raising the stress levels of the astronauts who already had the expectations of the world on their shoulders. During this tense time the astronauts had to wait for Mission Control to interpret the error code and decide whether it was a threat to the mission. The error code was looked up to mean 'Executive Overflow'. The problem was completely unexpected because although the astronauts had followed exactly the same procedure in the simulators back on the ground, the rendezvous radar switch was a dummy - no radar was actually connected so the computer didn't receive data, preventing it from becoming overloaded.

So how did the guidance computer software save the say? Well, it was written using a revolutionary scheduling system that could not only multi-task but understood the priority of the tasks it was assigned. In the event of an overload, it could ignore lower priority tasks and focus on what was essential. Lower priority tasks could be flushed and restarted when CPU time became available again. This is precisely what the Apollo 11 guidance computer did - essentially it self-recovered. NASA took a calculated risk that the landing would not be put in danger, and despite the 1202 error occurring a few more times during the descent, the guidance computer continued to do it's job, and shortly afterwards Buzz Aldrin and Neil Armstrong were walking on the surface of the moon.

The technology aspect of this story sounds familiar because today pretty much every computer and even smartphone has well executed multi-tasking, but this software was written in the mid-sixties at a time when programs had to be stored on core rope memory - or lol memory as NASA used to call it!

It would be twenty years later before the ground-breaking Commodore Amiga brought multi-tasking into peoples homes with it's AmigaDOS OS and Workbench GUI. The Amiga was famous for being able to run multiple simultaneous tasks at once while remaining highly response to the end user; often more so than modern day Window machines. Stay tuned for an Amiga post coming soon :)

Previously in this series: Apple capitalises on NextStep in a big way

Monday, 4 October 2010

Software design matters: Apple capitalises on NextStep in a big way

It's well known that Apple have had an amazing resurgence over the last ten years. In 1997 before the return of Steve Jobs, the company was nearly dead. The Macintosh hardware strategy had caused them real problems, and MacOS desperately needed replacing. Apple knew this and tried to develop a replacement - the Copland project - but this took years and ended in failure, bogged down by the requirement of full backwards compatibility with the legacy MacOS.

When Steve Jobs arrived back at Apple, he brought with him a secret weapon - NextStep. Famously, this is the OS that Tim Berners Lee used to develop the World Wide Web. It's a Unix-like OS but with a microkernel rather than monolithic kernel of Linux and many other Unix variants. The upper layers of the OS are written using object oriented principles and design patterns. Applications are developed in Objective-C, with built-in support for message passing. Available to all applications are cleanly separated libraries to help out with common tasks. These libraries are known as kits. If this sounds familiar it's because it is exactly the architecture of Mac OS X today, which is essentially a reskinned version of NextStep. An example of a well known kit is WebKit which Safari is built on top of.

In recent years Apple has been massively successful at creating or reinventing certain device classes such as the tablet or smartphone. Their success is largely because they tailor the user interface very well to suit the hardware and usage profile of the device, made possible by an investment in software architecture. Use of OO principles and design patterns such as Model-View-Controller means applications can be quickly redeveloped for new devices while sharing the same underlying code. This removes the maintenance issues of duplicate code.

Compare this to Microsoft. Their OS platform was heavily optimised to run on the limited PC hardware of the 1990's. Although this was an achievement, it came at the cost of clean design. For example, optimising load times was often the primary reason for grouping code into the same DLL, rather than because of the functions they perform. They had a dependency nightmare.

When Microsoft introduced tablet computers a full eight years before Apple's iPad launched, they used an OS that was almost unchanged from desktop Windows. They were probably well aware that a small Start button program launcher and window controls are not ideal for small touchscreen devices, but the architecture of Windows made it very difficult to make changes in a maintanabe way.

This is an often-overlooked and very important reason why Apple has jumped so far ahead of Microsoft in the market for new devices.

Note: Microsoft have recently been working very hard on untangling the Windows codebase, and the changes are already in Vista and Windows 7. These changes are already delivering significant architectural improvements to the Windows Server product line.