|
List Info
Thread: "ocaml_beginners"::[] Re: What is the typical way for handling incoming data by signal?
|
|
| "ocaml_beginners"::[] Re: What
is the typical way for handling incoming
data by signal? |

|
2006-09-13 10:35:22 |
Hi,
The solutions suggested by Rich and Jay are quite similar:
instead of informing
the master thread by signal, adding the data directly to the
source of master
thread. More generally speaking, suppose the master and
slaver needs to
get/put information from each other, in your solution, they
are actually
doing some kind of asynchronized *conversation* using data
source as media.
Yes, it works in many cases, probably even in my case if I
design the
conversation protocol to be safe (My real situation is much
more complex than
the example). However, a more general answer is what I
concern. If some
real time properties is necessary, e.g. the incoming data is
actually some
kind of demand and the master thread have to response in
time with the current
state information, is there any solution other than signal?
Actually, I don't quite like all the 2-threads solutions
for sake of
efficiency. Suppose I have to response some incoming query
averagely once per
hour, the threads will have to switch all the time.
The way I'd like is some system-signal-upon-data-arrive
functionality, however
it can only be provided by the OCaml VM if I'm not making
mistakes. I'm quite
curious about the following problems:
- What is the typical way to handle that in other
languages. It's only the
OCaml that doesn't provide such kind of signal or it's
the same for all
languages?
- For programs like windows-based interactive applications
where real-time is
necessary all the time, are there always more than one
thread running behind?
Thanks
-code17
Richard Jones <rich annexia.org> writes:
> How about having two threads. One is doing the
computation. The
> other is doing a select to listen on the data sources.
When data
> arrives for the second thread it saves it into some
internal data
> structure which the first thread can periodically poll
and consume.
> You don't really define how the first thread will use
the new data -
> does it need to be informed immediately or can the new
data sit in an
> internal queue for some time? Anyhow it sounds like
two threads is
> the way to go.
> Rich.
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] Re: What
is the typical way for handling incoming
data by signal? |

|
2006-09-13 14:50:49 |
In <87sliwhx5h.fsf gmail.com>, code17 <code17 gmail.com> typed:
> Yes, it works in many cases, probably even in my case
if I design the
> conversation protocol to be safe (My real situation is
much more complex than
> the example). However, a more general answer is what I
concern. If some
> real time properties is necessary, e.g. the incoming
data is actually some
> kind of demand and the master thread have to response
in time with the current
> state information, is there any solution other than
signal?
No. you need a signal, or something like it.
> Actually, I don't quite like all the 2-threads
solutions for sake of
> efficiency. Suppose I have to response some incoming
query averagely once per
> hour, the threads will have to switch all the time.
Most modern systems context switch all the time anyway.
Multiple times
a second, just to see if they should give some other user
process a
cpu slice.
> - What is the typical way to handle that in other
languages. It's only the
> OCaml that doesn't provide such kind of signal or
it's the same for all
> languages?
As far as I know, it's the same for all portable languages,
because
there's no standard API for this kind of functionality.
Even if you
restrict yourself to Unix and Unix-like systems, there's no
standard
API. So most languages that deal with it at all just expose
any
underlying system API, and let it go at that.
> - For programs like windows-based interactive
applications where real-time is
> necessary all the time, are there always more than
one thread running behind?
Well, it's not strictly necessary, but it's the standard
solution, at
least on Windows. So much so that people tell me there are
GUI
toolkits require it.
<mike
--
Mike Meyer <mwm mired.org> http://www.mired
.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more
information.
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] Re: What
is the typical way for handling incoming
data by signal? |

|
2006-09-14 12:29:17 |
On Wed, Sep 13, 2006 at 12:35:22PM +0200, code17 wrote:
> Actually, I don't quite like all the 2-threads
solutions for sake of
> efficiency. Suppose I have to response some incoming
query averagely once per
> hour, the threads will have to switch all the time.
The second thread will wake up only when the data arrives.
The rest
of the time it will be completely quiescent.
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses
a> - NEW!
Merjis blog - http://blog.merjis.com -
NEW!
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] Re: What
is the typical way for handling incoming
data by signal? |

|
2006-09-14 12:42:33 |
> The second thread will wake up only when the data
arrives. The rest
> of the time it will be completely quiescent.
Yes, but there's the added overhead of scheduling, no
matter how many
threads are active. But that's not to say that the overhead
isn't
neglible.
Jonathan
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] Re: What
is the typical way for handling incoming
data by signal? |

|
2006-09-14 12:29:17 |
On Wed, Sep 13, 2006 at 12:35:22PM +0200, code17 wrote:
> Actually, I don't quite like all the 2-threads
solutions for sake of
> efficiency. Suppose I have to response some incoming
query averagely once per
> hour, the threads will have to switch all the time.
The second thread will wake up only when the data arrives.
The rest
of the time it will be completely quiescent.
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses
a> - NEW!
Merjis blog - http://blog.merjis.com -
NEW!
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] Re: What
is the typical way for handling incoming
data by signal? |

|
2006-09-14 12:42:33 |
> The second thread will wake up only when the data
arrives. The rest
> of the time it will be completely quiescent.
Yes, but there's the added overhead of scheduling, no
matter how many
threads are active. But that's not to say that the overhead
isn't
neglible.
Jonathan
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
[1-6]
|
|