Posts

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...

lab 14 - map reduce

NAME lab 14 - map reduce functional grid programming DESCRIPTION I read about Google's MapReduce from Rob Pike's interview at slashdot. At the same time I've been studying Inferno's alphabet-grid (1) and am wondering if I can implement map reduce using alphabet. Here's an imaginary example % - {rng , | remote | mapreduce "{tq -1rm /n/tick/tick.bt} "{tock } | /create /tmp/result } Suppose that tick.bt is a log of time spent on tasks where each record is the timestamp, task and number of seconds spent on the task that instance. Rng produces 1 or more date ranges. Remote converts type /fd to an endpoint. Mapreduce will then split a date range, such as one year, into M smaller date ranges. For each subrange it calls rexec passing it the address of an available node, the subrange and map function as parameters. ...

lab 13 - flute

NAME lab 13 - implement the flute instrument from STK. DESCRIPTION I implemented more of the STK library but his time as a straight forward translation to a limbo module. Much of the protected classes and filters are in dsp.b as ADTs. They all share a similar interface that includes functions mk for building the object and tick for processing the next sample. The instruments are generally larger to implement but follow the same interface. They can be plugged into a signal module and then read and controlled from within signalfs. I've included a few simple modules that can be used to start a new instrument. I also tried to implement the more complicated Flute. It's close, but still doesn't sound right. It all needs a lot more debugging. To test the flute, % signalfs -a /mnt/dsp % echo add flute.dis flute > /mnt/dsp/ctl % sequencer /mnt/dsp/flute /dev/audio Sequencer...

lab 13 - sound library

No code to post tonight because it's unfinished. I'm converting all of STK to limbo, but not directly into signalfs. I'm creating a module that will contain all the sound sources, filters, and effects in the STK, with one ADT for each sound. This can then be used by signalfs to serve a file, which can be a combination of any of the ADTs, or by any other limbo app. Rog has suggested an alternative application using the shell alphabet. I will try this once the library is written. Rog pointed out how inefficient signalfs is in its current form. I agree; the performance is terrible, which makes it compleletly unusable for realtime sound support. This re-implementation will improve performance. But any hardcore DSP programmer is only likely to snicker at our attempt to implement DSP in limbo. At the end of the day I'm doing this to create a framework for ease of experimenting with DSP, not to create a sound system that will out perform all others. That is the tradeoff ...

lab 12 - oscilloscope

NAME lab 12 - implement an oscilloscope for signals from signalfs. DESCRIPTION I implemented an oscilloscope called scope to view the signals produced by signalfs, or other PCM data such as an iaf file stripped of it's header. % scope /dev/null It writes it's input to it's output, but it doesn't sound very good if directed to /dev/audio . It writes small blocks of samples with small delays between writes, making it sound very choppy. Scope tries to draw 25 frames a second, getting a tick from a timer, and reads 1/25th of a second of samples from the input, then draws it on a Tk panel. This is might be useful when recording input from a microphone % scope out.raw It takes as parameter the sample rate and number of channels, stereo or mono. CONCLUSION Not being able to listen and see the waveform at the same time makes it less useful than I hoped. H...

lab 11 - microsoft

I spent the time this evening downloading the Microsoft C/C++ toolkit and the SDK. I have only built emu for linux and plan9 so far. So it's time to start building an XP version. I also expect to be modifying the audio driver to add some more advanced features, such as 8 channels. While waiting for the downloads I found this site about audio networking interesting. A DTMF decoder would be a nice lab to do some night. I tried compiling the inferno distribution for XP. I'm missing LIB.exe. I used link /lib instead. Got most of it compiled, including emu.