sane-project-website/old-archive/1998-08/0004.html

112 wiersze
5.3 KiB
HTML

<!-- received="Sun Aug 2 14:33:56 1998 PDT" -->
<!-- sent="Mon, 03 Aug 1998 00:38:37 +0300" -->
<!-- name="Milon Firikis" -->
<!-- email="milonf@ariadne-t.gr" -->
<!-- subject="Re: SANEI_THREAD proposal" -->
<!-- id="" -->
<!-- inreplyto="SANEI_THREAD proposal" -->
<title>sane-devel: Re: SANEI_THREAD proposal</title>
<h1>Re: SANEI_THREAD proposal</h1>
<b>Milon Firikis</b> (<a href="mailto:milonf@ariadne-t.gr"><i>milonf@ariadne-t.gr</i></a>)<br>
<i>Mon, 03 Aug 1998 00:38:37 +0300</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#4">[ date ]</a><a href="index.html#4">[ thread ]</a><a href="subject.html#4">[ subject ]</a><a href="author.html#4">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0005.html">Yuri Dario: "Re: SANEI_THREAD proposal"</a>
<li> <b>Previous message:</b> <a href="0003.html">Hugo van der Kooij: "Re: segfault with Microtek Scanmaker 330"</a>
<li> <b>Maybe in reply to:</b> <a href="0000.html">Yuri Dario: "SANEI_THREAD proposal"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0005.html">Yuri Dario: "Re: SANEI_THREAD proposal"</a>
<!-- reply="end" -->
</ul>
<!-- body="start" -->
Yuri Dario wrote:<br>
<i>&gt; </i><br>
<i>&gt; Hi,</i><br>
<i>&gt; </i><br>
<i>&gt; I have wrote an initial API for thread support. It consist of 3 functions</i><br>
<i>&gt; </i><br>
<i>&gt; extern int sanei_thread_begin( void (*start)(void *arg),</i><br>
<i>&gt; unsigned stack_size,</i><br>
<i>&gt; void *arg_list);</i><br>
<i>&gt; extern int sanei_thread_kill( int pid, int sig);</i><br>
<i>&gt; extern int sanei_thread_wait( int pid, int *stat_loc, int options);</i><br>
<i>&gt; </i><br>
<i>&gt; that should replace fork(), kill() and waitpid(). They have the same parameters, except for thread_begin that require a</i><br>
<i>&gt; pointer to a function, a stack size and a pointer to data.</i><br>
<i>&gt; </i><br>
<i>&gt; I have included also the patches to the Umax backend as example. There is only one problem: the call to close(fds[1]),</i><br>
<i>&gt; must be avoided when using threads. I think it could be removed also on other platforms, because file handles are</i><br>
<i>&gt; closed automatically at process exit.</i><br>
<i>&gt; I have also added reader_fds to Umax_Scanner structure, so I don't need to create another data structure, as I wrote in</i><br>
<i>&gt; the past.</i><br>
<i>&gt; </i><br>
<i>&gt; If you find that changes useful, I will add them also to Mustek,Tamarack, SnapScan, Coolscan backends. Without that</i><br>
<i>&gt; changes, those backends wont work under OS/2.</i><br>
<i>&gt; </i><br>
<i>&gt; I have tested the code on an Umax Astra 610S, connected to my (old!) Adaptec 1542CF.</i><br>
<i>&gt; </i><br>
<i>&gt; Bye,</i><br>
<i>&gt; </i><br>
<i>&gt; Yuri Dario</i><br>
<i>&gt; </i><br>
<i>&gt; /*</i><br>
<i>&gt; * member of TeamOS/2 - Italy</i><br>
<i>&gt; */</i><br>
<i>&gt; </i><br>
<p>
I definitely agree that SANE should implement its own threading<br>
functions.<br>
<p>
I consider a bloat the fork staff and a bad thing to do from a backend.<br>
I believe backends should be scanner specific and do not intermix user<br>
interaction or call any OS functions. I actually believe that backends<br>
shouldn't be allowed to issue simple printf 's.<br>
<p>
Well, they don't. We have the DBG macro instead which is part of the of<br>
SANE API. If a backend does not do printf why should issue a fork()<br>
which is far more OS specific? I believe that the addition of threading<br>
to the SANE API is a good thing generally speaking.<br>
<p>
However I can't have an opinion to this specific proposal since I am not<br>
familiar with threads (Unix threads I mean, p or linux). I took a look<br>
to the proposed patch and it looked good, meaning it shouldn't break<br>
anything. The problem is that I saw some system specific parameters in<br>
the sanei_thread_begin. That's OK with me as long as it leaves room for<br>
a UNIX thread implementation. The problem is that I do not know about<br>
threads and I cannot judge that. What I mean is:<br>
<p>
1) Are these parameters meaningfull/usefull for a UNIX threading<br>
implementation.<br>
2) Does the UNIX threading implementation needs more/ others parameters?<br>
if yes, then they should be listed in the parameters list also.<br>
<p>
The other thing with the close stuff is more complicated. I thing it<br>
deserves extra discussion.<br>
<p>
Milon Firikis<br>
<p>
PS<br>
<p>
Please note that I do not consider the fork a bad thing under the SANE<br>
API specified threading function. I believe fork is bad if it is stray<br>
issued at a backend body.<br>
<p>
<pre>
--
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">majordomo@mostang.com</a>
</pre>
<!-- body="end" -->
<p>
<ul>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0005.html">Yuri Dario: "Re: SANEI_THREAD proposal"</a>
<li> <b>Previous message:</b> <a href="0003.html">Hugo van der Kooij: "Re: segfault with Microtek Scanmaker 330"</a>
<li> <b>Maybe in reply to:</b> <a href="0000.html">Yuri Dario: "SANEI_THREAD proposal"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0005.html">Yuri Dario: "Re: SANEI_THREAD proposal"</a>
<!-- reply="end" -->
</ul>