I recently stumbled across a website that says nice things about Cheap
Threads. Well, I didn't exactly stumble on it, I was Googling.
Anyway here's the URL for the main page:
http://www.zedshaw.com/projects/myriad/introduction/introduction.html
This site, by Zed A. Shaw, is about Myriad -- a framework for writing
servers. He uses Cheap Threads for multithreading, or multitasking,
or whatever you want to call it.
In the context of a server you have to worry about blocking yourself
while you wait for IO. The usual approach is to do your IO in
separate threads, or separate processes, so that you can be doing
other things while you wait for the IO to complete.
This approach doesn't work for Cheap Threads because the
multithreading is only simulated, rather than real. If one Cheap
Thread waits for IO, they all wait.
Myriad addresses this issue by using asynchronous IO. The idea is
that you tell the operating system to start some IO, but instead of
waiting for it to finish, you get control back immediately so that you
can continue doing stuff. Later, by one means or another, you find
out that the IO has completed (or perhaps encountered an error), so
you can use the results and keep going.
Never having written a server, I'm not in a position to evaluate
Myriad, nor Shaw's extended rant against the socket-as-file paradigm.
I also haven't looked at the Myriad source code. However if you want
to know how to do asynchronous IO you might want to take a look.
Shaw also makes a point that I hadn't considered. He says that
conventional multithreading packages can make your application hard to
debug because they do weird things with stack memory. Since Cheap
Threads uses only normal function calls and a single stack, it doesn't
confuse tools like debuggers and garbage collectors.
I'm still doing most of my debugging with printf...
----
This list still gets occasional spam, even though I have configured it
to allow posting only from members. Apparently the spammers are
signing up for robotic memberships. The only way I can prevent the
spam is to make the list moderated, so that I have to approve each
message before it is broadcast. I don't want to take that step unless
the spam becomes intolerable, and so far it's at a pretty low level.
Meanwhile I'm deleting the spam from time to time. I haven't tried to
be very prompt about it because by the time I can delete it, it has
already cluttered your inboxes anyway.
Scott McKellar mck9@...