sane-project-website/old-archive/2000-02/0223.html

172 wiersze
7.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>sane-devel: backend fork/reader-process &lt;-&gt; sane_read</TITLE>
<META NAME="Author" CONTENT="Oliver Rauch (oliver.rauch@Wolfsburg.DE)">
<META NAME="Subject" CONTENT="backend fork/reader-process &lt;-&gt; sane_read">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>backend fork/reader-process &lt;-&gt; sane_read</H1>
<!-- received="Sat Feb 19 09:31:47 2000" -->
<!-- isoreceived="20000219173147" -->
<!-- sent="Sat, 19 Feb 2000 18:33:19 +0100" -->
<!-- isosent="20000219173319" -->
<!-- name="Oliver Rauch" -->
<!-- email="oliver.rauch@Wolfsburg.DE" -->
<!-- subject="backend fork/reader-process &lt;-&gt; sane_read" -->
<!-- id="38AED3DE.7A67A25D@wolfsburg.de" -->
<STRONG>From:</STRONG> Oliver Rauch (<A HREF="mailto:oliver.rauch@Wolfsburg.DE?Subject=Re:%20backend%20fork/reader-process%20&lt;-&gt;%20sane_read&In-Reply-To=&lt;38AED3DE.7A67A25D@wolfsburg.de&gt;"><EM>oliver.rauch@Wolfsburg.DE</EM></A>)<BR>
<STRONG>Date:</STRONG> Sat Feb 19 2000 - 09:33:19 PST
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0224.html">Oliver Rauch: "Re: xsane bugs / suggestions"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0222.html">Karl Heinz Kremer: "Re: Xsane-0.55: scan resolution selection (Epson 1200S, CVS Sane)"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0226.html">Chris Pinkham: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0226.html">Chris Pinkham: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0252.html">Yuri Dario: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0258.html">abel deuring: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#223">[ date ]</A>
<A HREF="index.html#223">[ thread ]</A>
<A HREF="subject.html#223">[ subject ]</A>
<A HREF="author.html#223">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
Hi,
<BR>
<P>I though a bit about the way the most (all?) backends shift the data
<BR>
from the scsi buffer to the sane frontend:
<BR>
<P>a fork creates a reader_process that gets the data from the scsi buffer
<BR>
and shall prepare it for sane_read. For that it writes it into a pipe.
<BR>
<P>The main idea behind that is that sane_read() can be called with
<BR>
any request-size independent from the size of one scanline.
<BR>
<P>But for the scanner we do it totally wrong here:
<BR>
we write the data into a pipe that's size is on most systems about 4KB.
<BR>
When the pipe buffer is full the write command does not return until
<BR>
it was able to write the data into the pipe buffer.
<BR>
<P>So we try to press the scsi buffer data (32-128 KB) into a 4KB buffer
<BR>
what slows down scanning (creates a lot of pauses) and for that we create
<BR>
a second process that also needs lots of memory.
<BR>
<P>I think the pipe is the only reason why scanning large images with sane
<BR>
produces the backtracing of the scanhead and makes scanning very slow.
<BR>
<P>What can we do?
<BR>
<P>I see two possibilities.
<BR>
1) We do not write the data into a pipe. Instead we write it into a file.
<BR>
The disadvantage is that we have to store the image twice while scanning.
<BR>
The advantage is that a slow frontend (e.g. network scanning) does not
<BR>
slow down the scan speed (Backtracking is very slow).
<BR>
<P>2) We work with two buffers that have the same size as the scsi buffer
<BR>
(in the moment we use one of these buffers). sane_read reads the data from
<BR>
the one buffer while the other buffer is filled with the scsi/scanner data.
<BR>
As far as I can see the memory usage is not greater than in the moment
<BR>
because the existing fork already produces a second buffer of 32-128KB,
<BR>
but only one of the two buffers is needed/used at a time.
<BR>
<P>There are 2 ways to do this
<BR>
a) a forked reader_process writes the data into shared memory
<BR>
(this does not work on all systems, on other systems where no shared memory
<BR>
is available we could keep the pipe or b:).
<BR>
b) there is no own reader process, the backend itself calls sanei_scsi_read()
<BR>
when one buffer is empty. This is a bit slower but does not need shared memory.
<BR>
I am not sure if the scanning really slows down when we do not use an own reader process.
<BR>
All we need is a sanei_scsi_read routine that is able to do non-blocking (returns if no data is available).
<BR>
The coping the scsi buffer in the backend buffer does not take much time if the routine does not
<BR>
wait until data is available.
<BR>
If this works like I expect we do not need any fork or thread.
<BR>
<P>All this could be hidden in a sanei_ routine so the backend does not see anything about that.
<BR>
So a backend would not call sanei_scsi_read(), instead it would call sanei_scsi_read_buffered().
<BR>
<P>May be it would be a good idea to implement both (or all three with the exisiting) routines
<BR>
and let the user select the routine that works best for him.
<BR>
<P>Comments welcome.
<BR>
<P>Bye
<BR>
Oliver
<BR>
<P><P><PRE>
--
Homepage: <A HREF="http://www.wolfsburg.de/~rauch">http://www.wolfsburg.de/~rauch</A>
sane-umax: <A HREF="http://www.wolfsburg.de/~rauch/sane/sane-umax.html">http://www.wolfsburg.de/~rauch/sane/sane-umax.html</A>
xsane: <A HREF="http://www.wolfsburg.de/~rauch/sane/sane-xsane.html">http://www.wolfsburg.de/~rauch/sane/sane-xsane.html</A>
E-Mail: mailto:<A HREF="mailto:Oliver.Rauch@Wolfsburg.DE?Subject=Re:%20backend%20fork/reader-process%20&lt;-&gt;%20sane_read&In-Reply-To=&lt;38AED3DE.7A67A25D@wolfsburg.de&gt;">Oliver.Rauch@Wolfsburg.DE</A>
<P><P><P><P>--
Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A>
To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20backend%20fork/reader-process%20&lt;-&gt;%20sane_read&In-Reply-To=&lt;38AED3DE.7A67A25D@wolfsburg.de&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0224.html">Oliver Rauch: "Re: xsane bugs / suggestions"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0222.html">Karl Heinz Kremer: "Re: Xsane-0.55: scan resolution selection (Epson 1200S, CVS Sane)"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0226.html">Chris Pinkham: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0226.html">Chris Pinkham: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0252.html">Yuri Dario: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0258.html">abel deuring: "Re: backend fork/reader-process &lt;-&gt; sane_read"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#223">[ date ]</A>
<A HREF="index.html#223">[ thread ]</A>
<A HREF="subject.html#223">[ subject ]</A>
<A HREF="author.html#223">[ author ]</A>
</UL>
<!-- trailer="footer" -->
<HR NOSHADE>
<P>
<SMALL>
<EM>
This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>
: <EM>Sat Feb 19 2000 - 09:33:37 PST</EM>
</EM>
</SMALL>
</BODY>
</HTML>