Bill Sommerfeld's Weblog

Still Under Construction. Watch for falling objects


20050126 Wednesday January 26, 2005

Another production use of the infamous circularity detector.. Bryan asks:

    "Is this the only use of this infamous technique in shipping production code?"

Nope.

It took me less than a minute to find a place where the same technique was used in GNU Emacs, in src/print.c:print_object(), in the C implementation of the LISP s-expression printing code.   In LISP systems, the s-expression printer gets used from debuggers and the like; as with dtrace, it's generally bad form to get stuck chasing your tail printing out a broken data structure, so this hack is used a fair bit..

The emacs implementation is slightly different; instead of moving the scout out ahead, it instead has a "halftail" pointer lagging behind, moving at half the speed of the main pointer.  Actually, in the dtrace code in question, the half-tail approach might be slightly more efficient in the normal case where the data
structures aren't circular and the thing you're looking for is usually in the list.

(2005-01-25 21:09:04.0) Permalink

Comments:

Post a Comment:

Comments are closed for this entry.

Calendar

« December 2009
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today

RSS Feeds

XML
All
/General
/IETF
/IPsec
/Music
/OpenSolaris
/Solaris

Search

Links


Navigation