The READIN Family Album
(April 19, 2002)

READIN

Jeremy's journal

Books, which we mistake for consolation, only add depth to our sorrow

Orhan Pamuk


(This is a page from my archives)
Front page
More recent posts
Older posts

Archives index
Subscribe to RSS

This page renders best in Firefox (or Safari, or Chrome)

Saturday, February 16th, 2008

🦋 Another song about Sally

So I've been writing these short fiddle tunes over the past couple of months with "Sally" in the title. (You can listen to some of them here.) The new one tonight is called "Sally's Reel", though I'm not totally sure what conditions a song has to meet for a reel to be danced to it; I just sounds kind of reelish. ABC Format or PDF.

Update: renamed to "Sally's Dance" -- Gabe let me know that reels generally have a more even rhythm than this tune. And suggested chords for it!

posted evening of February 16th, 2008: Respond
➳ More posts about Songs

🦋 The Carter Family

Wow, this is excellent! While going through stuff to pack for our vacation, I just found a CD I had thought lost forever, viz. disk 1 of "The Carter Family" -- this box set about which I think, disk 1 is really amazing music, disks 2 through 5 vary in quality but have an unfortunate tendency towards corny.

posted morning of February 16th, 2008: Respond
➳ More posts about Music

Friday, February 15th, 2008

🦋 Never Let Me Go

In the interview yesterday (which features good humor and some real insight) Robyn recommends Kazuo Ishiguro's Never Let Me Go as "a gently devastating book." I had not heard of the book before but now I'm thinking it looks really interesting. -- Here is an interview with Ishiguro and some readings from the book. Onto the queue it goes!

posted evening of February 15th, 2008: Respond
➳ More posts about Never Let Me Go

🦋 Shanghai Love Motel

We're off to see them this evening, at the Yippie! Museum. Cool!

A little vacation coming up; on Monday we're flying away to St. Thomas for a week. I'm going to try and stay away from computers while we're there, unless a work emergency intrudes; so not blogging. Also I think I will take a vacation from my music: not bring along an instrument or an iPod, and only listen to new sounds. Send me your address (by Sunday) and I will send you a postcard.

Hmm, no SLM for us this evening. We did not feel up to the journey into the city -- instead we had a very nice dinner at home and watched Time Bandits, which Ellen has never seen before. What a great film -- I think it is the best ... fantasy? movie -- I hesitate to call Time Bandits "fantasy" but I guess all the lesser movies I associate it with are in that genre.

posted evening of February 15th, 2008: Respond
➳ More posts about The Movies

🦋 Nick and Robyn

Nick Lowe and Robyn Hitchcock are coming to the US! Dates are April 9 (NYC), April 11 (LA), April 12 (SF). How exciting!

posted evening of February 15th, 2008: Respond

🦋 Multiplexing

The fix is in -- the server is using poll instead of select, a new version has been built and delivered to the client, it can handle loads of clients. Here is the long and short of how you do it (without error-checking, which is dull*):

The Old Code

void select_files(int *fds, int nfds)
{
    int i, maxid;
    fd_set rset, wset;
    timeval tval;

    FD_ZERO (&rset);
    FD_ZERO (&wset);
    maxid = 0;
    for (i = 0; i < nfds; ++i) {
        FD_SET (fds[i], &rset);
        FD_SET (fds[i], &wset);
        if (fds[i] > maxid) maxid = fds[i];
    }
    tval.tv_sec = 5;
    tval.tv_usec = 0;

    select (maxid + 1, &rset, &wset, NULL, &tval);
    for (i = 0; i < nfds; ++i) {
        if (FD_ISSET(fds[i], &rset)) 
            read_file(fds[i]);
        if (FD_ISSET(fds[i], &wset)) 
            write_file(fds[i]);
    }
}

The New Code

void poll_files(int *fds, int nfds)
{
    int i;
    pollfd *pfds = (pollfd *) 
              malloc (nfds * sizeof (pollfd));

    for (i = 0; i < nfds; ++i) {
        pfds[i].fd = fds[i];
        pfds[i].events = POLLIN | POLLOUT;
        pfds[i].revents = 0;
    }

    poll (pfds, nfds, 5000);
    for (i = 0; i < nfds; ++i) {
        if (pfds[i].revents & POLLIN) 
            read_file(fds[i]);
        if (pfds[i].revents & POLLOUT) 
            write_file(fds[i]);
    }
}

In order to take advantage of the newly accessible file descriptors above 1024, you will need to add these lines to your /etc/security/limits.conf file:

(username)          soft    nofile          1024
(username)          hard    nofile          4096

I chose 1024 for the soft limit since most apps are not interested in the high number of files, and 4096 for the hard limit because I read on some message boards that performance will degrade above that number. Feel free to choose other values.

You then need to make the following calls from your code (or call ulimit from the script that starts your application):

    struct rlimit nofile;

    if (getrlimit (RLIMIT_NOFILE, &nofile) != 0) {
        fprintf (stderr, "Could not get NOFILE");
        exit (1);
    }
    nofile.rlim_cur = 4096;
    if (setrlimit (RLIMIT_NOFILE, &nofile) != 0) {
        fprintf (stderr, "Could not set NOFILE");
        exit (1);
    }

*If you're interested in the error-checking code, drop me a line -- I just don't feel like typing it out right now.

posted afternoon of February 15th, 2008: Respond
➳ More posts about Programming

🦋 The Polls

Saramago's Seeing is a terrific (or depending on how you feel about black humor, "horrible") book to be reading during the election year. I'm pretty sure, based just on the first chapter, that I would recommend it to Americans in 2008 before Blindness -- which I would certainly recommend, it's just not timely in the same way. It doesn't seem (so far) like knowledge of the previous book is vital to understanding this one.

posted morning of February 15th, 2008: Respond
➳ More posts about Seeing

Wednesday, February 13th, 2008

🦋 vim rules!

Here's a neat trick: let's say you forgot to close a code block somewhere in a large C source file, and you can't figure out where, and the compiler is not helping you. Try putting a } character at the very end of the file, placing the cursor on it, and presing the % key -- vim will jump to the most recent { which was not matched by a }. (Note: this will not work if you have unmatched {'s inside conditional compilation blocks, which is generally a bad habit anyway.)

posted afternoon of February 13th, 2008: Respond
➳ More posts about Programming Projects

🦋 1024

A good thing to keep in mind when you are trying to write a TCP server that will support thousands of simultaneous connections: the default ulimit for maximum number of open files on a Linux system appears to be 1024. A further thing to keep in mind once you figure out how to adjust that upwards: there is a reason the default maximum is 1024!

See, if you use select() to multiplex your I/O (like I do), you will be passing structures of type fd_set around. These structures can only deal with file descriptors less than or equal to 1023. Try and set bit 1024, and you will break your program. But fear not! There is a solution; that solution is to use poll() instead of select(); apparently poll() is the new standard. First I ever heard of it! Switching from one to the other seems like it's not too hard, though I've just now started.

posted afternoon of February 13th, 2008: Respond
➳ More posts about Projects

Tuesday, February 12th, 2008

🦋 Weather

It's the first real snow of the season! (I think -- I am remembering now that I wrote a similar post back in December or something, but that the storm blew over.) Sylvia and I had a snowball fight! Speaking of snow, look at these pictures, from Switzerland -- pretty!

posted evening of February 12th, 2008: Respond
➳ More posts about Sylvia

Previous posts
Archives

Drop me a line! or, sign my Guestbook.
    •
Check out Ellen's writing at Patch.com.

What's of interest:

(Other links of interest at my Google+ page. It's recommended!)

Where to go from here...

Friends and Family
Programming
Texts
Music
Woodworking
Comix
Blogs
South Orange