asynchronous IO vs. worker IO threads

asynchronous IO vs. worker IO threads

Post by lindahl » Tue, 24 Aug 2004 06:02:14


I'm implementing a multitasking library with non-preemptive
lightweight tasks (threads) using setjmp/longjmp and I'm trying to
support IO calls that won't block other tasks. There are two ways I
can do this, one, by providing worker threads, the other by using the
OS's asynchronous IO mechanism. The two OS's I'm really interested in
implementing the library effeciently for are Windows XP (OVERLAPPED)
and FreeBSD 4.8 (aiocb).

Now for my question: would it be better, given these OS's to implement
it using the worker IO thread mechanism, or use the asynchronous IO
mechanism? If the asynchronous IO mechanism for the OS is implemented
via worker threads, it would be better to implement my own IO worker
threads and use direct blocked IO, correct?

The majority of the IO will be for an object-oriented database system
where direct non-cached IO will be desireable - data being transferred
via random pages (4096 bytes) for the database file, and sequential
blocks (512 bytes), in sequence, for the logfile.
 
 
 

asynchronous IO vs. worker IO threads

Post by Arnold Hen » Tue, 24 Aug 2004 08:21:30


I'd guess worker threads would be the way to go (although you can still use
async i/o in combination with worker threads). Without threads, you can't
take advantage of SMP or hyperthreading. Also, even with async i/o, you can
still block - eg on operations which have no overlapped version (eg,
CreateFile can block on a slow network connection) and page faults.

 
 
 

asynchronous IO vs. worker IO threads

Post by Joe Seig » Tue, 24 Aug 2004 10:55:01


Why?

Joe Seigh
 
 
 

asynchronous IO vs. worker IO threads

Post by Claus Aan » Tue, 24 Aug 2004 13:05:59


Have you looked at statethreads?
http://www.yqcomputer.com/

--
A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
 
 
 

asynchronous IO vs. worker IO threads

Post by lindahl » Tue, 24 Aug 2004 15:55:17


The library isn't broad reaching, it's for a specific project of mine,
but I figured I'd put it in a library in case it was useful to someone
else at some point in time. It's to provide fast context switching and
low overhead for non-SMP architectures, where I need to provide
specific resuming and yielding of many tasks (where threads wouldn't
scale well). Granted page faults you can't get around, but this is a
penalty hit that I'll take to allow stateless scaleable tasks (stack
sizes are very minimal, so it works out well to have non-page
aligned/sized stacks).

I can go into the specifics of my needs, but I'm sure you understand
that its for a particular design, not for general application use.
 
 
 

asynchronous IO vs. worker IO threads

Post by Joe Seig » Tue, 24 Aug 2004 20:27:07


Using setcontext() to switch stacks is officially undefined, meaning you
can't assume it will work or not break something else. You can assume
the same or worse for longjmp(). It may work on some or most systems but
you should not assume that longjmp() is in any way portable for this
usage.

Joe Seigh
 
 
 

asynchronous IO vs. worker IO threads

Post by lindahl » Wed, 25 Aug 2004 03:01:04


Ahh, that will help quite a bit, thanks. I won't be able to use the
library directly since I need to incorporate heirarchal schedulers for
the project, but I'll look into how they solve the IO problem.

The real design behind all this is that I can localize events to a
geographical range and by maintaining a spatial index structure -
particularly a linear quadtree (nodes cannot overlap) - I know I can
asynchronously execute events in different spatial nodes, executing
all events in the parent before moving on to the events of its
children. Therefore, I want to take advantage of this as much as
possible by utilizing heirarchal schedulers/tasks. Since the order of
tasks and schedulers are on the magnitude of the size of the spatial
index structure, they must scale well.

On a side note, while this is out of the boundary of
comp.programming.threads, are there any other spatial index structures
that provide non-overlapping qualities besides quadtrees/octrees and
their linear versions?
 
 
 

asynchronous IO vs. worker IO threads

Post by stev » Wed, 25 Aug 2004 04:53:35

In article < XXXX@XXXXX.COM >,


FreeBSD already has a userland threads library. Look in
/usr/src/lib/libc_r/uthread
for guts.


FreeBSD uses non-blocking I/O (not the same as aio) and select in the
thread scheduler.

Have fun.
--
Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.8" / 37N 20' 14.9"
Internet: steve @ Watt.COM Whois: SW32
Free time? There's no such thing. It just comes in varying prices...