Mostly HarmlessJohn Alderson's Blog |
|
Tuesday Apr 03, 2007
D'you want -r with that?
Some vintage (thankfully) goofs in no particular order and not all by me. There is nothing like the curious abdominal tingle which accompanies the dawning realisation that an rm command has broken free of its moorings... 1. All C'ed up
I had just commented a large number of C source files and then moved on from that to edit a Bourne shell script to be run as root. One of the lines I added was: rm /tmp/scratch$$.* /* Clean up scratch files */This was such a narrow escape! There are almost no interesting regular files in "/". The main thing to put back on that machine was the symlink from /bin to /usr/bin, without which all of the shell scripts beginning "#!/bin/sh" cannot work.
Still, the error message
2. Dotty
.old .070996 .arch etc, led me (one fateful evening) to type:
rm -rf .*just above them. I feel clammy just thinking about it. The trees were very large so it did not concern me that this command had not returned after some minutes - but slowly I became aware that all was not well... It didn't help that this machine was in a kind of cluster with several others - each of which shared its entire filesystem via amd mountpoints with root allow privs. It was a long night... 3. Cron only too HTH
We already had an idea that there was some rm-ery afoot and asked him to check what the machine had been doing at the time. Following a hunch I took the source of rm and made a modified version which output file names instead of unlinking them and ran it on a local system with the same Solaris release. The rationale was that rm's file walk removes files and descends directories in directory entry order. Since most of the files in /usr are put there during installation and never subsequently deleted this file walk will tend to be the same on machines installed with the same release. I split the output of my "neutered" rm at ld.so.1, whose removal probably hung the machine. The remaining list of files was an almost exact match with the manifest supplied by the customer... ... who, in the meantime, had found a root cronjob which did something like: cd $SCRATCHDIR rm -rf *This is a well known danger spot. One should guard against the possibilities of $SCRATCHDIR being either null or not something that one could cd to. 4. Death by wrapper
rm -i. I have since encountered whole sites where this lunacy is standard practice.
The funny thing in the case of my friend was the speed with which the inevitable disaster overtook him. I think it was mere days before he typed rm * on some machine or other, expecting the friendly dialogue but getting only a prompt and a directory more echoey than he had intended. Thurber in The Bear Who Could Let It Alone concludes "It is better to fall flat on your face than lean too far backward". Posted at 10:59PM Apr 03, 2007 by John Alderson in Code | Comments[3]
Tuesday Mar 27, 2007
Matters Arising
The Boss is on the hoof. He is not abandoning us, merely relocating. Around here it is often feasible for a team member to move to a different country, or even hemisphere, and still remain in the same team - although it does feel a bit odd when that team member is the manager. The other odd thing is that he does not appear to have yet finalized where he is moving to. We had a team meeting (conference call) yesterday which underlined this situation. Algernon (the manager) decided to make it a video conference. We did not succeed in booking Brighton - the biggest and swishest meeting room - or even Filey, so we're all crammed into a broom-cupboard of an office with no windows and going by the name of Mother Iveys. There is a jumble of windows on the screen: us - looking like a submarine crew discussing whether to drop the ballast and cry Mayday, the guys from France, a couple of webcams and a blank window where Algernon is conspicuously absent. Risto I-am-not-a-Finn Kymmentäkivi and Arnie Shepherd (scourge of EPROMs and inventor of the WiFi deep fryer) unmute the phone to float a pre-meeting proposal about the reintroduction of doughnut days. Donna and Ursula, who have become oddly inseparable over the last couple of weeks, are not prompted to comment. Donna has her nose in a book entitled "Additive Cellular Automata, Volume 1", but she breaks off between chapters to refresh her lippie. The atmosphere is becoming oppressive when, at last, Algernon's window crackles into life. "Team! Glad to see [puff] you could all [puff] make it!" There is a confusing whirl of colour in the window, caused mainly by camera shake. Then it steadies and Algernon's face comes into view. He is looking bronzed and healthy and sporting surfer's sun-block on nose and lips. As he speaks he is rigging a spinnaker on the deck of a roomy-looking yacht which is coursing swiftly over a glittering sea beneath a sky which is blue from horizon to horizon... Posted at 12:03PM Mar 27, 2007 by John Alderson in Lake Guillemont | Comments[0]
Thursday Mar 22, 2007
Swotwiches
Most weekdays, in term-time, I am shuffling about the kitchen making packed lunches for wife and kids before 7 a.m. (Yes, I know, they should do this themselves.) Over time I have got fed up with those little plastic "sandwich bags" which come on a roll (I was fed up with clingfilm already). For one thing, the sandwiches change size and shape depending on what loaf we are using, while the bags are always the same size - namely too baggy or too tight. For another thing it seems like a large number of plastic bags to be throwing away just for the sake of defending an apple from a bit of mayonnaise for a couple of hours. So, one morning when I was feeling less groggy than usual I grabbed a bit of greaseproof and string and did it the old way. It was fiddly at first but after a few mornings I became quite slick at it. When we make things more convenient we often make them duller. I look forward to tying up the sandwiches now because it exercises a small competence, and it is possible to take pride in a neatly tied bundle. Anyway, things haven't stopped there. One of my brood reports that she is a bit behind on learning German vocabulary. She understands that just spending 10 minutes a day on this will make all the difference but she never remembers to do it. I note that she does, however, remember to eat her sandwiches. The consequence of this observation is shown below - and has been a runaway success. But is it Green Synergy, Lateral Thinking, or Just a Bit Weird?
Posted at 11:59AM Mar 22, 2007 by John Alderson in Life, Jim... | Comments[2]
Wednesday Mar 21, 2007
A Spark from The Past
To the right we see a CASIO fx80 - a 20th century design classic, leaning on the heavy cardboard box I made for it around the time I did my A-levels. These days it is regularly used for household accounting. Centre-stage is the pair of AA batteries that came with the calculator. I installed them some time in 1979 or 1980 and since then they have never left the battery compartment until I took this photo a few days ago. I took them out because the display was going dim. But when I put a new pair in the display was still dim - so it looks like the batteries have outlived the device they were powering! When digging one of today's "top of the range" batteries out of a remote control, which had been damaged by leakage after only a year, I would think wistfully "if only I could install a pair of those sublimely overspecified CASIO batteries". Now it looks like I can. I mean - what's a mere 27 years to one of these guys? Posted at 01:21PM Mar 21, 2007 by John Alderson in Life, Jim... | Comments[2]
Tuesday Mar 20, 2007
Incisive Thinking
Continued from here
Donna is importunate: "I've got the last piece, does that mean I get a prize then?". Ursula attempts to smoulder but technical types are unconvincing smoulderers. "It's the person who puts the last piece in who gets the prize, not the person who's holding some random leftover piece." "Alright then," says Donna, meeting Ursula's gaze levelly, and with one deft movement she removes a piece from the puzzle and replaces it with the spare. She seems to have made a good choice because it is immediately impossible to say for sure which piece has been exchanged. "Ah, that'll be the last piece then," she smirks, "This one wasn't a good fit." "Let me have a go," says Ursula and, as Donna obligingly passes her the piece, you might be forgiven for thinking Ursula was already intending to snatch it. She stands over the puzzle, peering at the piece and muttering, as though it were some more than usually delinquent doubly linked list. But the new spare piece refuses to be re-homed. Risto "I-am-not-a-Finn" Kymmentäkivi - he who is always running tomorrow night's build of Solaris and always seems to get the best chair in a crowded room - sits back in his chair and puts the tips of his fingers together. "The status of any remaining piece is difficult to determine. There may be still be an error in the puzzle. I mean, let's list the possibilities:
"How do we do that?" says Ursula looking up blearily. "Well, if it is itself a duplicate then we can simply compare it to every other piece in the puzzle. But that doesn't help if some other piece is duplicated or if the rogue piece is from some other puzzle. Plus it's non-optimal to look at every piece. Probably we should create a subset of all pieces with the same shape and then search within the subset for the best fit." If there is such a thing as a silent groan then Project Central is resounding with it at this moment. Donna is rolling her eyes and seems about to protest when Risto continues, "We can probably automate the process by breaking the puzzle into sections small enough to photocopy. If we photocopy the reverse side then I can get some pattern recognition software off the web to hunt down the candidate pieces. I mean, it's a slog but we don't want to put a picture up which might have a bug in it..." So the puzzle is carefully dismembered into about eight A3-size pieces and a curious cortège of assorted engineers and onlookers (stifling giggles) makes it's way to the photocopier/printer area. Donna has a somewhat stooped appearance and is less perky then usual. But then, as the first section is being gingerly slid onto the glass, she adjusts her ponytail and says airily to Ursula, "Hang on, can I see that piece again?" Ursula hands it over. "You seen somewhere else it fits?" "Not really. I was just thinking, why don't we ... I mean I just thought of a way, right, that we could further optimize this procedure." And, again, rather too quickly for anyone to stop her, she pops the piece into the gaping jaws of a shredder and presses the start button. She turns back to the stunned crowd (now numbering about two dozen people) and, looking radiant, exclaims "Does that mean I put the last piece in?" After the cheering dies down it turns out some folk are somewhat peeved by this turn of events (I think you could probably name a couple) but to my mind it puts Donna on a podium with Alexander The Great for sheer schutzpah if nothing else.
Later that day I find Risto loitering in the photocopier/printer area. He seems a little distracted. Posted at 01:40PM Mar 20, 2007 by John Alderson in Lake Guillemont | Comments[0]
Friday Mar 02, 2007
Donna
There's little sense of security in the computer industry. You can put your best work into a development project only to see it canned at the last moment owing to the need for "risk payload rebalancing" or a change in "goal-centric strategic realignment parameters". So I'm more than a little proud to point out here that the department in which I work has managed a series of arduous, complex and sometimes overlapping projects all to a satisfying conclusion. One of the keystones of our success in this regard has been the annual employment of student interns. There is nothing like a bunch of students to breathe new life into a flagging project. It's true they bring a certain amount of mental baggage under the general heading "Computer Science" but this stuff can usually be unlearned in a couple of weeks. Then for enthusiasm, creative flair and industry there is nothing to beat them. Our newest recruit is one Donna Jackson, formerly a nurse in the cardio-thoracic unit of our local hospital, who decided to swap bedpans for an Open University IT course. The intern who helped interview her could barely contain his emotion afterwards - blurting something along the lines of "But she knows (obscenity) all!". He clearly hadn't been listening when Donna was outlining her special interest in the Reluctant Surgeon problem and her attempt to analyse it using Varela's extension of the axiomatic algebra of Spencer-Brown. It's amazing how people succumb so easily to technical snobbery. So we employ Donna like a shot and assign her to work in the Lab Manager's office. This esteemed room has partition walls lined with framed jigsaw puzzles. It's the gnarly endgame for our current project which is a 5000 piece puzzle of Jackson Pollock's painting One: Number 31 which we began in November 2005 and came close to giving up on during the football world cup. With the end in sight there are quite a few people in project-central at lunchtimes. There's a lot of jostling and the atmosphere can sometimes get quite heated when there's a disagreement about which inspired blob of paint goes with which. Donna, however, has been a marvel. She seems to complete whole chunks before anyone else gets in - as if she has been fitting them together in her sleep. There's a prize for the person who puts the last piece in, so yesterday lunchtime, with only a few pieces left, the room is particularly full of myopic geeks trying to palm their own stashes of avant-garde fragments and pecking competitively at the table. I have decided to sit this one out so I am testing a new consignment of Nepalese tea (which definitely contains more than tealeaves) when the victorious shout goes up. It is followed almost instantly by protests and incredulous gasps. Peering in at the door of project-central I am amazed by a curious scene. My colleague, Ursula Resplandor (she who can diagnose three data-corruption panics before breakfast), is stretched halfway across the enormous puzzle with a forefinger triumphantly pinning a piece which looks like a deformed chromosome. The puzzle is undeniably complete - and therein lies the problem. For Donna (the voice of protest) is still holding a piece and looking decidedly wronged. Now, everyone is familiar with the misery of finishing a jigsaw puzzle and discovering that the hole which nobody could find a piece to fill is there because that piece really is missing - but how often do you finish a puzzle with a piece left over? The thing is unheard of! It has the same sort of unexpectedness quotient as wandering up to the old drinks machine, drawling "Tea, Earl Grey, hot" only to see it swing into action to serve up exactly that. ... to be continued ... Posted at 07:39AM Mar 02, 2007 by John Alderson in Lake Guillemont | Comments[3]
Thursday Dec 14, 2006
In search of a good cuppa
Kettles are not permitted in the office. In fact all domestic appliances are forbidden. For instance, you won't see anyone using hair straighteners at their desk. The drinks available gratis from the vending machines also feature in Dr Seuss's book The Lorax, in which we see them being used to pollute a lake where once "the humming fish hummed". The "hot" water provided by these machines is nowhere near boiling (health & safety) and so barely awakes the full flavour of a Vintage Darjeeling or Assam (organic). What to do? The solution turned out to be a concealed kettle. We positioned the offending article in an empty desk pedestal with a deep filing drawer, drilled a hole in the back and through this fitted a hose which fits over the spout of the kettle. The trailing end of the hose runs between cubicle partitions all the way to the outer wall where we have integrated it discreetly with an air conditioning outlet. The tricky part was concealing the kettle flex which must plug in to a highly visible integrated socket strip on the top of my desk. We purchased the thinnest 13amp rated flex we could find and adapted an unused ethernet socket on the same strip to supply mains power and earth on three of its pins. A similarly adjusted RJ45 was attached to the end of the kettle flex. Now it was possible to plug in and operate the illegal device in a manner entirely above suspicion, and many clandestine pots of tea were enjoyed by all. My boss, naturally, is unaware of this arrangement. One day he brings his young daughter into work - along with his state-of-the-art Armani Laptop to keep her occupied. This laptop (not to take anything away from the daughter) is his pride and joy. He has graced it with multiple bootable partitions so that he can run a selection of Linux distros, Windows, Mac OS X, Solaris 10, Nexenta and others. He once showed me OS/2 Warp on the thing and we all suspect that somewhere it is harbouring DRDOS and CPM. It has got to the point where you can't have a simple conversation with the man without his mentioning GRUB or chain loaders and their various problems. Anyway. He stations his daughter, Louisa, in the desk next to mine and boots up the machine for her to use. We're all gallantly chatting to her, for she is a tad shy, when suddenly her eyes widen to the size of billiard balls and she points her little finger at the laptop screen in front of her.
I get a sick feeling in my stomach as my boss steps back from my desk with his hand in his mouth.
Posted at 10:06PM Dec 14, 2006 by John Alderson in Lake Guillemont | Comments[2]
Saturday Dec 09, 2006
SGRT meets The Reluctant Surgeon
As promised, I attempt to shine the beneficent light of an analytical troubleshooting method into the dark recesses of the pesky Reluctant Surgeon problem. The method in question is Sun Global Resolution Troubleshooting which is Sun Microsystems' implementation of Kepner-Tregoe's Resolve product. I will not give an exhaustive account but just show ways in which conscientious application of the method might uncover the concealed sticking point in the problem. I was prompted to do this by the following question:
I can think of three ways in which SGRT might offer the key of this problem to a trouble shooter. Approaches 1 and 2 use the following problem statement. Problem Statement SGRT encourages us to frame a problem statement in terms of a divergence from what "should" pertain. The "should" here is that the surgeon should operate. The surgeon is not operating and we need to find out why. First Key - Trivial SGRT generates a set of questions which are used to establish precise details of what the problem IS and what it could be but IS NOT. (More about this later.) The answers to these questions are then used to ask more speculative questions to determine differences between the IS and IS NOT cases. Having established initially that this particular surgeon won't operate but another one might, SGRT would lead us to ask a question like What is different or unusual about this reluctant surgeon?" to the person posing the problem. An honest answer in the UK would have to supply the information that the surgeon is a woman because, in the UK, only 6% of consultant surgeons are - so it is unusual. If the "IS NOT" surgeon was a male (likely) then the sex of the reluctant surgeon would count as a difference. Of course, in a real problem situation the person reporting the problem may ignore differences that they consider irrelevant, but this is why SGRT encourages us to "Question to the void" saying (repeatedly) What else is different or unusual about this surgeon? until even the most banal answers have been given. However, this method is inadmissible for our problem because we are not allowed to ask questions. We can only suggest solutions. This situation is not uncommon in the real world. A customer might not be able to interrupt his production to provide more data, or we may be foolishly working on a problem while key people are unavailable (i.e. burning the candle at both ends). So we have to suggest our own answers, and this too offers a key. Second Key - Requires devotion The first of the "IS" questions establishes in what object the problem resides. Answer "The surgeon" because "The surgeon IS reluctant". We then move to the "IS NOT" side of the same question:
Here is where we need to be conscientious. It is easy to fill in the blank here and simply answer "Some other surgeon". If this were an IT problem with an SFW series 1000+8i then this would be like answering "some other computer" or "my laptop". The idea is to find something as similar as possible to the problem object which nevertheless does not exhibit the problem. e.g: "Another SFW series 1000+8i in the same room" or "An SFW series 1000+4i". In our case this makes us analyse the idea of kinship. We may think the surgeon is a deluded man. Perhaps he knows the boy slightly and is lying because he doesn't want to operate. Perhaps his use of the word "Son" is aspirational. We must put all that aside and simply list the surgeons who legitimately could and could not operate. If we are conscientious our table will have a "cannot operate" column including the word "mother". Third Key - Shift of focus It's irritating. We are not allowed to ask questions but the room is full of grinning idiots who know the answer and tell us it's easy. So that suggests a new problem statement.
If we repeat the analysis with this problem statement then we will certainly start analysing our assumptions because the problem is now seen to be inside our own head. Because we have redefined the problem statement we can now start asking and answering questions about our mental model of the problem. We might be lucky and trip over our fatal assumption while listing all the assumptions we know we have made. For instance, we might look at what elements are missing from our model (since it is we who are missing something); the other driver in the crash, the other medical staff, the other relatives (presumably telephoned) of the boy... This list will also throw up the key insight that this is not a problem with a surgeon but a problem with inconsistency. It is a "someone must be lying" problem when we know they are not. The IT equivalent might be a silent data corruption problem where the entire datapath is protected by ECC logic. The hidden assumption is that data is being corrupted somewhere (because that's what it looked like when the problem statement was drawn up); the actual cause is that the application at one end of the path was built with later header files than the application at the other end. Addressing the inconsistency is key. In the surgeon problem, focusing on the inconsistency causes us to give equal weight to the man driving the car as to the surgeon. After all - the fact that he is the boy's father is equally as problematic as the fact that the surgeon claims to be. "Someone must be lying". If we ask the question "Who else might have driven the boy to the match but did not?" we are even more likely to think of the mother than if we ask it of the surgeon. All in all the conclusion seems to be that an analytical troubleshooting method is only as good as the degree to which you follow it conscientiously. It is not just about filling in a template but about evaluating what you know and seeing what parts of it are wanting, and looking critically at whether what you know really justifies the current problem statement. Posted at 12:36AM Dec 09, 2006 by John Alderson in Problem Solving | Comments[0]
Friday Dec 08, 2006
Attack of The Phones
My desk here in Lake Guillemont is a haven of tranquillity. It is kitted out with a special shelf 23 OUs (O'Reilly Units) long on which I have placed packets of tea from every corner of the globe. It's the sort of place where a bloke can unwind on a Monday after an exhausting weekend assembling flatpack for in-laws. Although it is a hotdesk I have discovered it is even feasible to doze off at it for short intervals - provided I have taken the precaution of attaching chair to desk with a long bike padlock. I have also erected a nameplate with a fictitious name on it, which is a good diversionary tactic although perhaps not strictly ISO 9000. So you have a pretty good idea now of the kind of restful ambiance I am enjoying this Monday after a weekend spent luring a mouse from an extensive dwelling made out of fibreglass insulation and catfood (our cat is more of a watcher than a doer) and positioned in a quiet cul-de-sac with good access to local amenities behind our cooker. And you will empathize strongly with the sense of nervous collapse which steals over me when the phone unexpectedly rings and on answering it I hear:
- Er... - Do you presently own a mobile phone sir? - Um... yes, NO! - You don't own a mobile phone? - No, yeah I do. - And can you tell me who supplies your network and how long the contract has to run?
- (imperceptible sigh) Is the phone switched on sir? - No, hang on, I'll just do it. Who did you say you were with? - TETNEF Mobile! You may not have heard of us before but I am in a position to offer you some very attractive terms... Sure enough, my search for telesales outfits in Bhutan has returned several addresses - and one of them is right in the cross hairs of the Higgins gridref. Gotcha! Better hope he's a local employee. I fire up SatNavSniffer given me as a clandestine quid-pro-quo by someone in the haulage business and hunt for delivery vans manoeuvering in the vicinity. Where there are IT offices there are always IT office fitters. Meanwhile George is delivering rapid fire features of multiple mix-and-match TETNEF tailorable tariff options and I am countering with a list of the exotic benefits of some imaginary phone company I have dreamed up on the spur of the moment. Make him work for that bonus. Yes! A lorry not two miles away and it's even toting an onboard camera. I squirrel down the SatNav uplink and assume control of the puny device. The Bhutanese translation site has no trouble with the command "Next right" and soon the necessary unicode is winging its way to the cab. The camera is not bad. I'm getting about one frame every five seconds. It's drizzly but otherwise a bright evening in that part of Bhutan. The lorry pulls up facing the windowed side of an office block. It looks very new - perhaps I should have tried hacking into the office surveillance system instead of commandeering this truck. I send a translation of "Vehicle malfunction detected. Please exit cab and await assistance". Time to bring George in on this little game.
- What is this...? - Take a look at the parking lot. See the man standing by the truck? - Yes...? - He works for me George. He knows who you are. If you ever, ever , ring this number again he'll pay you a visit. Do you understand? - He's visiting me tonight actually. He's my brother. Garrrgh! The office surveillance system! George rings off abruptly and I bruise my hand on my desk. Posted at 11:15PM Dec 08, 2006 by John Alderson in Lake Guillemont | Comments[1]
Wednesday Nov 22, 2006
The Dispossessed
My desk is hot! This is just another way of saying that it is not really mine. One trip to the water cooler may result in a bloodless coup. The occupying force has tidy hair and owns a briefcase and a Gucci laptop. He has replaced my post-it notes with his own post-it notes which are anathema to me. My post-it notes said comforting things like " I lurk nearby until he gets up to visit the water cooler. As I move in for the kill he receives new mail. The laptop makes a sound like an incoming cruise missile and scares me half out of my wits. I lose the element of surprise as tidy-hair guy swings around the corner with his water cup brimming. Looks like another day in the Lab for me - well, white noise helps you think they say... Posted at 07:41PM Nov 22, 2006 by John Alderson in Lake Guillemont | Comments[0]
Tuesday Nov 21, 2006
Lake Guillemont
It is beautiful today in Lake Guillemont, so I decide to make a serious investment of time gazing out the window. My first impulse would be to describe our surroundings as "landscaping by those who would rather have knocked up a few more buildings" but that would be grossly unfair. For half a mile we abut mixed woodland owned by the M.O.D. I could hardly call it "undisturbed" since at any moment its peace can be shattered by apocalyptic booms which seem to come from every direction. At lunchtime it fills up with dog walkers who are used to the din. More surprisingly their dogs seem inured to it too - calmly raising a leg to a tree trunk while I find myself diving for cover in the nearest shell hole. I conclude that these phlegmatic beasts are either war veterans themselves or simply stone deaf. So the woods are not undisturbed but they have been here a long time. There are many mature hardwoods so there is a good mix of wildlife and the sort of general untidiness which reassures the observer that nature is being allowed to get along quite well thank you. And it is that untidiness which the builders of this modern, spacious and curiously earthquake-proof office have successfully allowed into the grounds. We have manicured lawns along the front, paying lipservice to the norms of business park gardening; but they run up against a rugged moat within which a riot of waterweed conceals dark things stirring. Workmen at perpetual tea-break on the bridge claim to have seen monstrous fish leap clear of the water. They speak wistfully, as if planning to return at night with a rod and a warm jumper. We have a central park with little paths and benches surrounding a spinney. But this is not planted, rather conserved from what was there before. It is something like chalky heathland; wirey and straggly and bursting forth with hundreds of different species of sedge and hawkweed and trefoil. The botanist I once was can't really remember the name of anything, but rejoices nonetheless. And we have the lake itself (a pond really) which teems with dragonflies in the Summer and anarchy all year round. As I watch, a vast heron flops onto the water and begins to struggle with a fish the size of a coelecanthe. I am so mesmerised that I fail to notice at first that my tea has gone cold and my boss is standing next to me. He peers at the same scene through a pair of field glasses as the heron begins to prevail. "Ah John, John", he murmers in a voice of distant disappointment, "it's an Ardea herodias eat Esox lucius world..." Some people know too much for their own good. Posted at 01:28AM Nov 21, 2006 by John Alderson in Lake Guillemont | Comments[0]
Friday Nov 10, 2006
truss -d -u on syscall stubs
Using truss -d (or -D) gives timing information which may help identify where delays are occurring in a process. However, it does not timestamp both the exit and entry points on a system call so it is not always obvious if the delay is really in the system call or in the program's cogitations. Dtrace or TNF probes with microstate accounting will get accurate per-system call duration information, but there is also a cheap and cheerful way using truss itself where these other methods are not available or appropriate and where you don't mind the relatively high probe effect of truss. Since system calls are made from within libc stubs you can use the library call tracing facility of truss to trace entry and exit of the stub. So for open[64](), close() and various read flavours you could use:
$ truss -d -u "libc::*_open*,*_close,*_*read*" wc -l /etc/group
Base time stamp: 1163198817.8709 [ Fri Nov 10 15:46:57 MST 2006 ]
16824: 0.0000 execve("/usr/bin/wc", 0xFFBFF144, 0xFFBFF154) argc = 3
16824: argv: wc -l /etc/group
16824: 0.0097 resolvepath("/usr/bin/wc", "/usr/bin/wc", 1023) = 11
16824: 0.0099 resolvepath("/usr/lib/ld.so.1", "/usr/lib/ld.so.1", 1023) = 16
16824: 0.0101 stat("/usr/bin/wc", 0xFFBFEF18) = 0
...
16824: 0.0496 -> libc:_open64(0xffbff296, 0x0, 0x1b6, 0x0)
16824: 0.0500 -> libc:__open64(0xffbff296, 0x0, 0x1b6, 0x0)
16824: 0.0504 open64("/etc/group", O_RDONLY) = 3
16824: 0.0505 <- libc:__open64() = 3
16824: 0.0508 <- libc:_open64() = 3
16824: 0.0511 fstat64(3, 0xFFBFEF10) = 0
16824: 0.0512 brk(0x00024AC8) = 0
16824: 0.0513 brk(0x00026AC8) = 0
16824: 0.0514 fstat64(3, 0xFFBFEDB8) = 0
16824: 0.0515 ioctl(3, TCGETA, 0xFFBFEE9C) Err#25 ENOTTY
16824: 0.0516 -> libc:_read(0x3, 0x23b44, 0x2000, 0xff28b5f4)
16824: 0.0520 read(3, " r o o t : : 0 : r o o t".., 8192) = 8192
16824: 0.0521 <- libc:_read() = 8192
...
Posted at 10:58PM Nov 10, 2006 by John Alderson in Code | Comments[0]
Thursday Oct 26, 2006
Mother! That's it!
I commend to you this small addition to the world's bank of colloquialisms. When I was at school some evil friend had laid upon my little circle the curse of the Reluctant Surgeon Problem. All of us had attained enlightenment (after various embarrassing intervals) save one poor unfortunate, who was still wrestling with it two days later. I think he was working on some scheme involving identical twins and amnaesia. Anyway, in the middle of a rather subdued physics lesson he suddenly cried out "Mother! That's it!" to general laughter and the consternation of the physics teacher. This phrase then became popular with us for any situation where a long awaited insight finally arrives - something like "eureka!". This is a modest attempt to revive it. I admit it sounds a little outré, but you will have the quiet satisfaction of knowing what it really means. Posted at 06:56PM Oct 26, 2006 by John Alderson in Problem Solving | Comments[0]
Wednesday Oct 25, 2006
Mysteries of Cognition - part 2
So, what is so interesting about the Reluctant Surgeon Problem? What always piqued my curiosity was not that a few people take days to figure it out but rather that no one (ok, almost no one) answers it instantly (me included). The most common exchange goes something like:
No. Ok. The surgeon is the real dad but the guy killed in the crash is the boy's adoptive father, right? No.. So the boy has two biological fathers, using IVF! No... (sigh) Even if the fourth suggested answer is the correct one this little paddle through the first three takes some explaining. Somehow the brain is battling an unconscous assumption. The usual explanation is simply one of cultural stereotype, surgery having been traditionally a male dominated profession. I think this is only the beginning. If you think in pictures it may be that as the boy is wheeled up to the operating table your mind has provisionally supplied a male surgeon standing ready with his instruments, even if you yourself are a woman. However, I think the popularity of medical documentaries and soap-operas featuring many high-powered female consultant surgeons these days makes this a less than complete explanation. The language of the problem may be a second part of the explanation. There are no feminine pronouns. The boy is a boy. He and his father are off to a football match - which conjures more masculine imagery (OK -that's cultural stereotype too...) By the time we reach the operating table the problem-solving part of our mind is primed with fathers and sons. This may take the form of a flawed syllogism: All fathers have sons The surgeon has a son Therefore the surgeon is a father I think the cultural stereotype is still key. I assume that a mother driving her daughter to ballet would far more frequently elicit the instant answer the problem deserves because it does not work at cross purposes with the stereotype. But what about a father driving his daughter to ballet? I reckon substituing a daughter for a son would also help weaken the hold of the unconscious assumption. This is a testable prediction as long as too many people don't read this blog (there doesn't seem to be any danger of it...) The third part of the explanation is simply that the problem is presented as a problem at all. As soon as we are told something is a problem we are put on guard for impending mental strain. What's more, we are told it is a lateral thinking problem. It is not. It is a vertical thinking problem. Ask a computer with only limited grasp of natural language and family relationships and it will spit the answer out instantly. But knowing that we have to identify a "problem" forces us to make the surgeon a man - even though this thought is never consciously articulated. To me this surgeon story (since it is not a problem at all) is the archetype of a very real and pernicious enemy to the person who solves problems for a living - the "unconscious assumption". In problem solving we are often asked to "list our assumptions", but it is hard to list assumptions of which we have no awareness. So I am going to return to this surgeon thing again and look at how a formal problem solving method might fare at cracking it - and to see if such a method needs enhancing to tickle unconscious assumptions. More of a bleeding lecture than a blog you might say, but then you can always go and watch an episode of ER or Holby City (ah, Connie...) instead... Posted at 07:53PM Oct 25, 2006 by John Alderson in Problem Solving | Comments[2]
Tuesday Oct 24, 2006
Mysteries of Cognition - part 1
The following problem (sometimes, oddly, classed as a lateral thinking problem) is as old as the hills, but in spite of this there never seems to be a shortage of people who have never heard it, but many of these do have the stamina to persevere with it for hours until they have satisfactorily figured it out. I will say more about it in a later posting, but for now here it is: A father and his son drive off to see a football match. After an enjoyable game they are driving home in the dark when they are involved in a horrific traffic accident. The father is killed outright and the son is rushed to hospital with internal injuries. But in the operating theatre the surgeon, on seeing him, exclaims "I cannot operate on this child, he is my son!" How can this be so? Posted at 02:58AM Oct 24, 2006 by John Alderson in Problem Solving | |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||