This page renders best in Firefox (or Safari, or Chrome)
READIN
READIN started out as a place for me
to keep track of what I am reading, and to learn (slowly, slowly)
how to design a web site.
There has been some mission drift
here and there, but in general that's still what it is. Some of
the main things I write about here are
reading books,
listening to (and playing) music, and
watching the movies. Also I write about the
work I do with my hands and with my head; and of course about bringing up Sylvia.
The site is a bit of a work in progress. New features will come on-line now and then; and you will occasionally get error messages in place of the blog, for the forseeable future. Cut me some slack, I'm just doing it for fun! And if you see an error message you think I should know about, please drop me a line. READIN source code is PHP and CSS, and available on request, in case you want to see how it works.
See my reading list for what I'm interested in this year.
READIN has been visited approximately 236,737 times since October, 2007.
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
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
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
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.)
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
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
One thing I spent a lot of time wondering about while I was reading Blindness was, how is Saramago going to end this story? It seemed like it would be really difficult to pull off without being either corny or dull, or both. Saramago came through, I'm glad to say, and managed to make what could easily have been a rote, formulaic ending vital. The doctor's wife's moment of doubt and fear in the final paragraph will blow your mind -- it is the whole book contained in a few sentences.
Saramago has a later book called Seeing, which I bought in December when I bought Blindness, intrigued by the similar titles -- it turns out the first few pages of that are printed in the end of this edition of Blindness -- it is another story featuring some of the same characters, and with reference to this one. How exciting! That will be my next read, assuming I can figure out where I put it down, which was predictably not "on the bookcase".
The final pages of Blindness are very strong, I think everything that has been rough and disorganized in the novel is crystallizing here, coming into focus. (I have not gotten quite to the ending, though I think I will finish it tonight.) I opened the book to get some pull-quotes and realized that really everything starting from where I stopped yesterday shines with such clarity as to be difficult to exerpt. The scene in which they bury the neighbor of the girl with dark glasses; the wedding proposal of the one-eyed man; the church with the defaced artwork... Here: I have not yet quoted any passages featuring the dog of tears.
...It won't be long before we have outbreaks of epidemics, said the doctor again, nobody will escape, we have no defenses left, If it's not raining, it's blowing gales, said the woman, Not even that, the rain would at least quench our thirst, and the wind would blow away some of this stench. The dog of tears sniffs around restlessly, stops to investigate a particular heap of rubbish, perhaps there is a rare delicacy hidden underneath which it can no longer find, if it were alone it would not move an inch from this spot, but the woman who wept has already walked on, and it is his duty to follow her, one never knows when one might have to dry more tears.
Well ok, and also the church -- this really seems to me like a little masterpiece, a visual impression worthy of Buñuel:
She raised her head to the slender pillars, to the high vaults, to confirm the security and stability of her blood circulation, then she said, I am feeling fine, but at that very moment she thought she had gone mad or that the lifting of the vertigo had given her hallucinations, it could not be true what her eyes revealed, that man nailed to the cross with a white bandage covering his eyes, and next to him a woman, her heart pierced by seven swords and her eyes also covered with a white bandage, and it was not only that man and that woman who were in that condition, all the images in the church had their eyes covered, statues with a white cloth tied around the head, paintings with a thick brushstroke of white paint, and there was a woman teaching her daughter how to read and both had their eyes covered, and a man with an open book on which a little child was sitting, and both had their eyes covered, and another man, his body spiked with arrows, and he had his eyes covered, and a woman with a lit lamp, and she had her eyes covered, and a man with wounds on his hands and feet and his chest, and he had his eyes covered, and another man with a lion, and both had their eyes covered, and another man with an eagle, and both had their eyes covered, and another man with a spear standing over a fallen man with horns and cloven feet, and both had their eyes covered, and another man carrying a set of scales, and he had his eyes covered, and an old bald man holding a white lily, and he had his eyes covered, and another old man leaning on an unsheathed sword, and he had his eyes covered, and a woman with a dove, and both had their eyes covered, and a man with two ravens, and all three had their eyes covered, there was only one woman who did not have her eyes covered, because she carried her gouged-out eyes on a silver tray.
Update: the woman carrying her gouged-out eyes on a silver tray is Saint Lucy, the patron saint of the blind.
posted evening of February 11th, 2008: Respond ➳ More posts about Blindness
The Yes We Can video is great, it has to be said, granted I had a couple of criticisms -- It's pretty sweet. Even better, the McCain camp's response:
(Yeah yeah, I know it's not from the McCain camp -- I just like to pretend. Dig the tall guy looking down at his music to make sure he's got it right.)
Microgravity experiments: here's video from the International Space Station. I especially like the Symphony of Spheres but they're all good. In space, you can drink your tea with chopsticks!