|
Tech Talk
Saving and Restoring State
 |
By Karl Rehmer
Senior Software Engineer
|
It’s been a long day, trying to chase down a bug. You haven’t
found the bug, but now it’s time to go home and you need to shut
down. But what about the work you’ve done? You have spend a lot of
time setting up tracepoints and breakpoints with conditions and
attached subprograms at just the right places to help you debug. You’ve
temporarily disabled some of the breakpoints and tracepoints. You’ve
set up a set of registers and expressions to watch. You’ve changed
the default bases for display to be what you need. When you shut
down you’ll loose all of this and will have to redo all of this
when you come back to work and resume trying to find the bug. And if
you’re like most of us, you won’t be able to remember all of the
things that need to be done just to get things set up like they
were.
The SCORE® debugger has a solution that we call "save and
restore state". This feature is present with the SCORE® debugger
in SCORE® releases 2.4g and later.
When you are ready to shut down, bring up the debugger command
window. This can be done by clicking on the icon that looks like
">_" in the toolbar for debugger windows or going to
the "Debug" menu, selecting "Windows...",
checking the box for "Command" and then clicking on
"OK". The upper part of the window will show a history of
recently executed commands. The lower part allows you to enter
commands for the debugger. Enter the command "SAVE STATE
<filename>" without quotes and with <filename>
being the full path name for a file where you would like to save the
current state information. In response to this command the debugger
will create a debugger subprogram that will create any currently
existing breakpoints and tracepoints, disable those that are
currently disabled, set up watches for the registers or expressions
currently being watched, and save set the base and size environment
information to what is currently in effect. You can then exit the
debugger and shut down. Note that when using GUI mode debugging, it
is important to use the full path name for the file or otherwise it
will be written in what the main part of the debugger perceives as
the "current directory" which may not be what you expect.
When you return to resume debugging your application, you will
have to start your application from the beginning. However, you can
easily reset your tracepoints, breakpoints, watched registers,
watched expressions, base and size information just by executing the
debugger subprogram when you shut down. There are several ways you
can do this. If you are debugging in the sequential mode you can
enter the command "RESTORE STATE <filename>" where
the filename is the one you specified when you shut down. If you are
debugging in the GUI mode, the simplest thing to do is to go do the
"Debug" menu, and then to "Subprograms - Execute
Subprogram..." menu choice. Enter the <filename> or
browse to the file and click "OK". (There are no
parameters.) The state items previously saved will be restored.
Note that since the file to restore state is a debugger
subprogram, it is a text file that you can edit if you wish. Also,
you do not have to execute the subprogram immediately when you start
the debugger, but can do so at any time that is appropriate.
[
Back to Top ]
Unusual Solutions - Part
1
By Linda Rising
risingl@acm.org
www.lindarising.org
Last month, I described the problems two
mountaineers faced as they climbed the 21,000-foot Siula Grande in
the Peruvian Andes. Joe Simpson and Simon Yates survived only
because they "broke the rules." Yates cut the rope that
bound him to his partner, Simpson. This freed Yates to walk back to
camp, but it was also the beginning of a series of events that
enabled Simpson to make it back alive. Following climbing "best
practices" and not cutting the rope would have meant death for
both climbers.
Since telling you that story, I have uncovered
several examples of unusual solutions. The recent tsunami disaster
has touched us all. Try as we may, those of us in this country
cannot imagine what the experience would have been like—for those
who saw the wall of water heading toward them, for those who
perished under the waves, for the survivors who must face life with
family members dead and homes and hopes destroyed.
Sri Lanka was hit harder than some other countries because the water
is so deep off the coast. Apparently, a tsunami picks up speed over
deep water and slows down over shallow water. Also, the tsunami was
traveling perpendicular to the fault zone that caused the
earthquake, and Sri Lanka was directly in its path.
This is why Bangladesh, where the water is shallow for about 130
miles off the coast, and where the land was not perpendicular to the
fault line, suffered relatively little damage, with two people
killed. In Sri Lanka more than 30,000 died. The unusual solutions I
describe in this article are from Sri Lanka.
The first unusual solution comes from Yala National Park, Sri
Lanka's largest wildlife reserve, home to hundreds of wild elephants
and several leopards. The unusual twist in this story concerns the
animals in this park. Dr Ranjith Premalal De Silva, an expert in
geological information systems and disaster management, said, "Yala
is known for its elephants. But not a single elephant died when the
park was hit by the tsunami. And Yala was one of the worst-hit areas
in Sri Lanka."
The animals in Yala National Park probably felt
tell-tale signs of the tsunami three or four days ahead of the
strike and that is a likely explanation for the absence of any
reports of animal deaths from there.
Since the early 1950s, there has been
considerable research, mostly in China, on animals and earth
tremors. Researchers have discovered that domesticated animals are
able to sense earthquakes before they are felt by humans.
"If domesticated animals can sense
earthquakes days in advance, wild animals should be able to do that
even better. The natural abilities of animals are much more evident
in wild animals than in domesticated ones," De Silva observed.
Virtually all animals have sensors, which tell them about forest
fires and the presence of predators.
But wait! Aren’t we animals? De Silva
suggested, "Scientists should interview people to find out if
they saw any unusual behavior among the animals in the days prior to
the disaster. But unfortunately, there may not be many human
survivors in the Yala Park who can tell the tale."
Indeed—while no animals died as a result of the
tsunami, hundreds of visitors and many Yala park staff were killed.
After reports of escalating numbers of casualties
began pouring in from sites throughout the affected area. I was not
surprised to hear that the solution that was being proposed to avert
similar future scenarios was technical. I see this all the time in
software development trouble spots. In the case of the tsunami
disaster the proposed solution is better monitoring and warning
devices. In software it’s always a better tool—even when the
problem is pretty obviously one of mis-communication—a peopleware
problem. The solution is always better technology.
Does that mean that we humans are doomed? Surely
we’re as smart as our animal cousins! There are some hopeful signs
in the following report of an unusual solution.
The Andaman and Nicobar Islands are part of
India, located in the Indian Ocean, almost 1,000 miles to the east
of the mainland, and comprise an archipelago of over 500 islands, 38
of which are populated. There are five aboriginal tribes that
inhabit these islands: the Jarawas, Onges, Shompens, Sentinelese,
and the Great Andamanese. These tribes make up about 12% of the
islands’ population and keep very much to themselves, living in
remote areas, much as their ancestors have done for centuries. The
history of these tribes can be traced back to the Mesolithic and
upper Paleolithic eras (20,000 to 60,000 years ago).
Most of the modern settlements on Andaman and
Nicobar are around Port Blair, the capital, on one of the
northernmost islands. The islands are also home to scientific teams,
the Coast Guard, and the Indian military forces.
The village of Kakana on Nicobar was considered
an ideal village that neighboring villages tried to emulate. It had
a power station, electricity, a school, banks, shops, concrete
houses, roads, and television. When the tsunami hit, Kakana was
essentially reduced to rubble.
Other villages along the island coastlines
experienced similar horror. A week after the disaster, the area
reported 700 dead and over 3,000 missing.
The southern islands of the Nicobar group are
closest to the epicenter of the tsunami. 95% of the aborigines live
on the central and southern Nicobar Islands. Many of the smaller
islands of the Nicobar group were totally submerged by the tsunami.
A few days after the tsunami, a Coast Guard
helicopter was surveying Sentinel Island, home of the Sentinelese
tribes. The pilot spotted some tribesmen on the beach and headed
toward them. The tribesmen immediately sent an angry shower of
arrows at the helicopter that conveyed the message: we have
survived; leave us alone!
Later surveys by the Coast Guard confirmed that
all five indigenous tribes had survived by moving to high ground.
According to Dr. V.R. Rao, the director of the
Anthropological Survey of India (ASI), "The tribal members get
wind of impending danger from biological warning signals like the
cry of birds and the change in the behavioral patterns of marine
animals. As a result there have been no casualties reported among
these five tribes."
The ASI is documenting this research to help save coastal
populations from similar disasters in future. "Early warning
systems developed by their forefathers and adapted successfully by
the tribal members must have sent the first alarm signals and given
them time to run for safety," said Rao.
The hopeful message in this story is that these simple,
unsophisticated people saved themselves when many of the larger
bases on the islands had almost been flattened and hundreds of
civilians were surprised by the tsunami and killed.
In some cases, just like the aboriginal tribes,
we learn from our surroundings. We are aware of what’s going on
around us and we save ourselves from a horrible fate. I saw one
software development team realize as the deadline was approaching
that they weren’t going to be able to deliver what had been
promised. Instead of proceeding ahead in complete denial, they had a
meeting and devised a brilliant plan.
They were honest with the customer. They said
they wouldn’t be able to deliver the planned functionality on
time, but they could deliver the most important piece early. The
customer really wanted that important piece, was happy to get it
early, and didn’t mind waiting a bit for the rest. Win-Win! A good
example of a team that paid attention and faced the impending
disaster instead of ignoring it at their peril.
The last story is a special one for me. As many
of you know, I’m a believer in retrospectives—not only for
development projects—but also for all of us in our daily lives.
This story shows how learning from the past can have a tremendous
impact, not only for you who have learned from experience, but also
for all those whose lives you touch.
The report of Victor Desosa, headman of the
village of Galbokka, in Sri Lanka, explains why even though the
village was hit hard by the tsunami, only one life was lost. In
similarly affected areas, as many as one-third to one-half of the
residents were swept away.
Desosa had been a merchant marine sailor for 23
years, until 1987. In the summer of 1982, he was on his ship outside
the harbor of Valparaiso, Chile, while most of the crew had gone
into town. Suddenly, the ship began to shake. He ran to the deck,
looked at the city and saw the buildings swaying.
"I prayed to God! What will happen to the crew? Of course, what
was happening was the earthquake that killed so many people, though
none of the crew. This terrible thing made a great impression on
me," Desosa reported.
"On December 26th," Desosa said, "I was down by the
ocean, talking to a friend, and I saw that the water was shaking. I
thought that there was some problem in the middle of the sea."
Then the water level began to rise.
"I did not know exactly what was happening, but the feelings I
had in Chile were back and I knew we had to get out of our village.
I began to hoot and shout to people to run inland, to run up on the
hills."
Fellow villager Kanathi Jaykobi said, "He can hoot very loudly,
and we heard him shouting, ‘Go! Go!’ and we understood that we
must run. And we did."
As people ran, they spread the word. Soon the entire village and
others who lived nearby were running uphill, while right behind
them, the 20-foot wall of water that claimed so many other lives
smashed into their village.
"We got to the high ground, I thanked God," Desosa said.
"I am so grateful I was able to use my experiences from so long
ago to such good purpose now."
Learn from the past. It’s the best way to grow.
Otherwise, as George Santayana observed, "Those who will not
learn from history are doomed to repeat their mistakes." Or as
Hyman Rickover quipped, "Learn from the mistakes of others. You
can't live long enough to make them all yourself." We all make
mistakes. That’s not what will hurt us—as long as we learn from
it!
For those project teams who do conduct
retrospectives or "postmortems" the list that is created
of "what should be done differently" often looks like the
list from the last release. What does this show about how well we
are learning? As David Parnas noted, "We don’t just want to
complete a project; we want to learn about completing projects while
completing projects." I’ve written other articles about
retrospectives, for those who want to learn more about this process.
If you have some stories of unusual solutions, I
would love to hear them. I’ll have another interesting one to
share next month. Thanks for reading!
References
"Tsunami Scientists Hear Stories," William Hermann, The
Arizona Republic, Jan. 14, 2005.
"Ancestral early warning systems saved
Andaman tribes," India News, Jan. 3, 2005.
"Animals sensed tsunami days ahead,"
P.K. Balachanddran, Hindustan Times, Jan. 5, 2005.
 |
About the Author
http://www.lindarising.org
risingl@acm.org
Linda Rising has a Ph.D. from Arizona
State University in the area of object-based design metrics.
Her background includes university teaching as well as work
in industry in telecommunications, avionics, and strategic
weapons systems. She is the author of numerous articles and
has published three books: Design Patterns in
Communications, The Pattern Almanac 2000, and A Patterns
Handbook. Follow this link for information regarding her
latest book "Fearless Change: patterns for introducing
new ideas".
http://www.cs.unca.edu/~manns/intropatterns.html |
[
Back to Top ]
|