Posts

inferno wiki

i have setup a demo inferno wiki for wikifs on inferno.

lab 30 - wikifs

NAME lab 30 - wikifs for inferno DESCRIPTION I ported plan 9's wikifs to inferno. There were various aspects of the application I wanted to learn about--such as, the cache, the transforms from wiki syntax to html, the method for using html templates, and the details of creating the namespace--that it seemed worthwhile to write it in limbo to absorb it all. I also had a hunch I'd be borrowing a lot of the code for my next file system. The differences between the original and the port are small. The one significant difference is the approach to locking data structures. The original uses locks for the Map and the Cache memory as well as file locks for accessing disk. For the port I attempted to avoid the memory locks altogether. One reason being that when the Flush message is received I attempt to kill the proc processing the request, but that might leave stray locks. The f...

lab 29 - embedded graphs

Image
NAME lab 29 - embedded graphs DESCRIPTION Taking inspiration from Mathematica 's notebook user interface, I tried implementing graphs embedded within the shell window, wm/sh . The idea being that a scrolling page of graphs, text and images is easier to manage than many overlapping windows. I feel this especially while I'm iteratively running commands, generating data and viewing graphs. The shell window provides a history of activity. By including other windows in that history I can look back at the graphs I generated, what data generated them, what command was used to generate the data, and so on. With overlapping windows this context can be lost. Wm/sh used in this way now behaves as a rudimentary window manager. It is easy to imagine ways in which it becomes inconvient to use. Such as interacting with two windows separated by a large block of text. But it still might ad...

REST

I took a break from this blog and inferno coding for March and April. During that time I've been reading about web services, deconstructing Google's offerings and AJAX , and most importantly reading about the REST architectural style for the web. I like the approach taken by the Plan9 wikifs to offer web pages by first writing a filesystem, then just mount that into the httpd namespace. I'd like to experiment with that approach further to implement RESTful services like del.icio.us . I've been porting wikifs to Inferno to learn more how it's done. I'll post that soon. I'd like to update the Inferno httpd to support HTTP 1.1 and basic authentication. That shouldn't be hard considering Plan9's supports this and the code is very similar.

lab 28 - side effects

NAME lab 28 - side effects DESCRIPTION I was planning on just implementing side effects, but it turned out to be a little more complicated than I thought, and then I got sidetracked into changing the evaluator to handle more of the shell semantics. The file lisp7.b implements setq but it is limited in that in cannot change the type of the value referenced by the symbol. % eval {setq a `{b c d}} (b c d) % eval {setq a `b} error at type mismatch (b c d) Fixing this requires me re-implementing the sepxrs library to remove pick from the ADT. I'll follow up on this later. Mixing shell and lisp syntax The final parser in the Sussman and Steele paper The Art of the Interpreter puts dynamic scoped variables back into the evaluator. It maintains two environments, one for lexical and one for dynamic binding. Instead of havi...

lab 27 - sh sexpr

NAME lab 27 - sh sexpr DESCRIPTION The implementation of the lisp dialect in lab 26 had some problems. For each car or cdr operator I recursively descended the syntax tree rather than holding the lists in memory in a more convenient fomat and simply taking the head or tail of the list. I did not want to build further on this implementation. Instead I wanted to rewrite eval to use the sexprs (2) module and convert the sh's syntax tree to an s-expression. Converting from the syntax tree to an s-expression is pretty easy to do, though it took me a while to remember the method. The first file lisp1.b is a brute force implementation, which of course once I got working I remembered the method I should of used. % load ./lisp1 % eval {a {b} c} (a (b) c) % unload ./lisp1 The second file lisp2.b maintains a global stack of lists of sexp...

lab 26 - greenspun's rule

NAME lab 26 - greenspun's rule DESCRIPTION Let me state up front, I do not know much about lisp. I've always been aware of it but never saw it's benefits so never used it. However, recently I've begun to read more about it, particularly the essays by Paul Graham, and his book On Lisp (which I'm still reading, on and off). I went a bit further and read Steele and Sussman's paper The Art of the Interpreter. Also, as a symptom of my Mathematica envy I became curious about symbolic programming languages, computer algebra systems, and how these are based on lisp dialects. I started playing with Maxima and yacas and also Mockmma And so I think I finally got what lisp was about. (I still have much more reading to do. It's funny how a large and rich subculture within computer science suddenly opens up to you when you read about its core language. I hav...

lab 25 - accumulator generator

NAME lab 25 - Accumulator Generator DESCRIPTION The problem by Paul Graham is stated here and I quote Write a function foo that takes a number n and returns a function that takes a number i , and returns n incremented by i . I thought I'd attempt it in sh (I'm already assuming it's not possible in limbo). Here's my first attempt, which is wrong. % subfn foo { n=$1 result={i:=$1; n=`{fc $n $i +}; echo $n} } % n := 0 % x=${foo 3} % $x 1 4 The problem is we can't create another accumulator generator in the same scope, since it will overwrite the variable n. Sh uses dynamic variable binding instead of lexical binding, as used by lisp. The shell paper /doc/sh.ms:/lexical.binding/ mentions the issue and proposes a workaround but it doesn't really solve the stated problem. Here's a solution that incor...

lab 24 - google api

NAME lab 24 - call google api from inferno DESCRIPTION I looked around to see what was available. Inferno has no WSDL or SOAP support, and limited xml. However, most of the SOAP messages are boiler plate, so we just need a program to handle the http. The program svc/webget/webget is something I hadn't noticed before. It serves a file /chan/webget which we can write GET and POST messages to and read back the result. With this in mind I tried writing shell scripts to read and write the SOAP messages to the google api url. I needed to debug webget a little because the POST didn't work. The changed files are attached below. The google api download came with sample SOAP messages. I inserted my key (removed from the attached files), and placed the string PHRASE where the search phrase was to appear. The shell script runs sed on the file replacing PHRASE with the actual search p...

lab 23 - tickfs

NAME lab 23 - annotating a file system DESCRIPTION i have tried out some experiments with annotating the filesystem; really, several iterations of the same idea. my latest attempt is tickfs , which i think comes close to doug mcilroy's idea of a metadata file system. each file served by tickfs is a binary relation, the key is usually an absolute pathname, and the attribute is defined by the name of the relation. each relation is also bi-temporal. it's a historical record of changes to each key, value pair and it determines whether a key, value pair is true at a given time. adding metadata is simple, % echo ${quote i . /doc/sh.ms 'the inferno shell' } > /n/tickfs/desc % echo ${quote i . /doc/sh.ms 'rogger peppe' } > /n/tickfs/author the dot indicates the current time, but any time represented as seconds since the epoch can be given. q...

lab 22 - news aggregator

NAME lab 22 - news aggregator DESCRIPTION Rssget downloads an RSS xml file indexes it into tickfs . Then using tickquery , which should be copied into /dis/svc/httpd you can query the RSS aggregator using address http://localhost/magic/tickquery. % mkdir rss % cd rss % mount -c {tickfs} /n/rss % touch /n/rss/index /n/rss/desc /n/rss/chan /n/rss/title % svc/httpd/httpd& use localcron to call rssget periodically on your favourite news feeds. tickquery looks if the first keyword begins with 'date:' the rest of the word is treated as a rng(1) and restricts the results to within the date range. For example, to search for RSS entries since 1st of the current month mentioning google, date:1, google or show me all entries collected on the 21st of the current month date:21 Here is a demo of this service. more interesting examples I have yet to work out. it gets more ...

lab 21 - popi

NAME lab 21 - popi DESCRIPTION Ported popi from the book Beyond Photography - The Digital Darkroom which is online and many of the examples from the book should work. I took the C code, translated it to limbo, then tried to add the trig functions and polar coordinates. I referenced Rich Burridge's version of popi to get ideas while adding the extra features. See the guide file here for many of the examples from chapter 3 The combination of the program and the online text makes a good example of an active essay. While reading the text the user can type in the formulas and edit them to explore further into the tool and it's possibilites. It enhances reading of the text and understanding of the tool. CONCLUSION This took longer to debug than I expected and I still have doubts about parts of it. The polar coordinates when used as a target do not work, rounding erro...

lab 20 - libmux

NAME lab 20 - libmux in limbo DESCRIPTION To learn about mux in detail I tried to implement libmux in limbo. It actually resembles the mux from libventi more than libmux. They are pretty similar. I was going to do a detailed description of the mux in devmnt but it turns out this has already been done here by nemo. When I get this working it can be applied to the venti lib for session rpc, to build a libfs for direct client 9p interaction, bypassing devmnt, and for application protocol muxing, say for sam. This is a partial implementation. I didn't complete send , recv , gettag and settag functions, so this has not been tested. I'm just posting it here now so I don't lose track of it. I'll come back to it later, maybe writing more for the Venti library or libfs. This is more an excercise to understand the workings of libmux and venti's session rpc. FILES...

lab 19 - wm

NAME lab 19 - understanding wmclient DESCRIPTION In trying to understand wm (1) and its supporting libraries wmclient (2), tkclient (2), and titlebar, I modified them to resemble (if you squint) rio. I haven't adopted rio's menus or button controls. Here's a screenshot . I began with a copy of wmclient. I wanted to peel away the layers between the application and wm. I removed the dependency on titlebar and created a border that would manage the window. I removed whatever else I thought was unneccessary. I ended up with myclient which talks directly to wm. Window management is based on button clicks on the border. Button 1 moves , button 2 reshapes, and button 3 deletes the window. I liked the window management so I wanted to use that for all windows. To copy the border changes back to wmclient.b was easy. But most windows programs in inferno use the tkclient. F...

lab 18 - mux

NAME lab 18 - mux DESCRIPTION Much of my recent reading has led me back to various implementations of a multiplexer. This is an important and powerful abstraction and I want to understand it better. I know very little about it now. I'd like to implement one in limbo, for example to multiplex the link between sam and samterm as suggested in the protium paper. Hence my interest in sam in the earlier lab. Here is a some of the things I've been reading recently about multiplexers. See if you see a pattern. J. Hickey's Master thesis at MIT implements mux for plan9 which puts a 9p multiplexer into user space and provides asynchonous IO for user threads. Search 9fans for multiplexing where there is some interesting discussion on the use of multiplexers in plan9. For example, an idea by rog and russ's response And futher proposals by russ ...

lab 17 - samterm

NAME lab 17 - fixup inferno samterm DESCRIPTION There's an inferno version of samterm intended for connection to remote sam running on unix/nt/plan9. It looks like it hasn't been updated for the latest tkclient interface. Get it working. Simple edits to add samtk.b:/^tkcmds/ and samtk.b:/^cmd/ One of the bigger changes I made is to spawn a new proc samtk.b:/^tkproc/ for each file to handle events from the toplevel chan. This was the quickest way I could think of doing it. It might be more correct to create arrays of channels like those already in samterm.m:/Context:/ but that seemed like a lot more work. I use the idiom of returning the pid samtk.b:711 so I can kill the proc when the file is removed, otherwise the windows would be left hanging around. I added the pid to samterm.m:/pid/ Menus were placed wrongly when middle or right clicking in an edit window. Menu...

lab 16 - canto

NAME lab 16 - set up a styx service for active essays DESCRIPTION I created a readonly unauthenticated styx service for readers of IPN, who have inferno installed, and want to read the lab notes in acme and execute the embedded scripts. From here on I'll use the term canto for active essays authored and "read" (rather to execute or chant) in the Inferno environment. This entry in my notebook is my first attempt of the new style. It describes the files and formats of the service. Mount the service and open acme on the file for this lab. mkdir /n/canto mount -A tcp!canto.hopto.org!6700 /n/canto acme -c1 /n/canto/16/index.txt Each canto is in a numbered directory containing the following files: text the raw contents of the notes in man (6) format post.html the text file converted to html using man2html for sending to the blog. guide the...

active essay

in the second post to this blog i talked about wanting this lab notebook to be more interactive, with something like mathematica notebook or squeak project in mind. after reading more about squeak, and thinking again of what i want, i'll try and describe how i'll proceed with this notebook. Alan Kay and Mitchel Resnick have used the term "active essay" to describe a publication that includes computational objects. Resnick describes them as "new forms of narrative expression, in which manipulable computational objects are integrated with text, graphics, and video." Kay in particular stresses the point that the objects in the essay can be deconstructed to learn how to put them together again. The squeak environment uses many visual elements targetted at children for building simulations of ideas they are learning in school--a constructionist view of education for math and sciences. Kay believes the most important use for modern inexpensive personal compute...

squeak

been very busy of late (new baby!) and had no time for inferno programming after work. I hope to get back into some kind of routine within the next month. TODO list clean up dsp module and write more instruments try out the alphabet typesets with dsp, tickfs, grids write a general btree module for indexes port plan9 sort to inferno ... Aside from inferno I've been playing with the squeak smalltalk environment. I've been very impressed with this. The morphic interface and etoys scripting is very cool. It got me thinking about how these and other ideas could be transferred to inferno, and then I got into a kind of thought paralysis--I got too confused. another interesting paper I read yesterday was protium an infrastructure for partitioning applications. i wonder if some ideas for session persistence could be explored within inferno. i downloaded panda3d a 3d game and simulation engine with python scripting. wouldn't it be cool to link this to inferno as a new in...

lab 15 - cluster file

NAME lab 15 - cluster file DESCRIPTION I'm still curious about layering of filesystems. Ds (3) was an example I looked at before writing signalfs. Another example was cryptfs (lab 2). Ds currently resides in /os/port/devds.c. A while ago I moved it into /emu/port/devds.c but hadn't made any use of it. I have wanted to use it for a rudimentary cluster file system, so I ported ds to limbo to play with distributed files and further explore files that are built from layering of other file systems. I translated the C code and used styxservers to manage the simple, one level namespace. Here's some testing. This is really as much as I've tested it so far. % for (i in `{seq 0 9}) {zeros -v $i 1024 8 > /tmp/chunk ^$i} % echo cat c1 /tmp/chunk2 /tmp/chunk3 >ds/ctl % echo cat c0 /tmp/chunk0 /tmp/chunk1 >ds/ctl % echo mirror m0 ds/c0 ds/c1 > ds/ctl % cat ds/ctl cat c1 /tmp/chunk2 /tmp/c...