Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #14401

Re: Non-blocking asynchronous execution

From Arnold Doray <invalid@invalid.com>
Newsgroups comp.lang.forth
Subject Re: Non-blocking asynchronous execution
Date 2012-07-26 02:44 +0000
Organization A noiseless patient Spider
Message-ID <juqav7$tkd$1@dont-email.me> (permalink)
References <jup4k8$u1a$1@dont-email.me> <7xsjcfs5yb.fsf@ruckus.brouhaha.com>

Show all headers | View raw


On Wed, 25 Jul 2012 17:48:28 -0700, Paul Rubin wrote:

> Forth traditionally uses cooperative multi-tasking.  The task switcher
> runs at i/o operations or when you call a special word called PAUSE.
> I've looked at the eforth implementation and it is extremely simple and
> fast.  There are many other ones that are basically similar.

This isn't about multi-tasking, although that is an interesting problem 
too. It's about scheduling tasks to occur at predefined times in the user 
application. 

> 
> I don't remember if eforth has a timeout scheduler but again, it's
> old-school, look at an OS book for how to do it.  Basically you have a
> queue of pending timeouts, and a periodic timer interrupt, and a task
> that wakes up on the timer interrupt to check the timeout queue and wake
> up any task that has a timeout due.  If you want to get fancy and handle
> a lot of timeouts, you can use various O(log n) or O(1) lookup data
> structures to store the timeouts and be able to quickly find the next
> pending one, but if you have just a few timeouts you can use a search
> list.  I seem to remember that early versions of Linux had an O(n)
> scheduler and they eventually replaced it with an O(1) scheduler.
> 

With a timer thread, you'd still have to start a separate thread to run 
the task; otherwise, the solution would block other scheduled tasks from 
running. I don't think that's what's going on here, I get the impression 
that it is much lighter weight than this, but I could be wrong. 

I'm also ignorant of how to start threads in Forth. Is this 
implementation specific? 

> Elsewhere I posted a url for a paper about the GHC scheduler.  I'd
> expect Erlang works about the same way.
> 

Many thanks for the GHC paper. Erlang claims to be able to schedule 10K 
of lightweight "threads" (not OS threads), and I suppose this is what the 
V8 runtime on which runs node.js does too. Doing something similar in 
Forth is what I am interested in. 

> Node.js is crude by comparison: all the scheduling happens in the user
> application, interspersed with the application logic, giving a pattern
> called "inversion of control".  Whether that's good or bad is a debate
> that has gone on for decades.

Well, there is an explosion of apps using node.js, so the usefulness of 
this approach is being proven practically. But looking at the examples 
presented in the clip, I felt that Forth might be a much better fit. It 
would certainly cut the verbose JS code by quite a bit!

Cheers,
Arnold

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-25 15:50 +0000
  Re: Non-blocking asynchronous execution Mark Wills <markrobertwills@yahoo.co.uk> - 2012-07-25 09:09 -0700
    Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 02:48 +0000
  Re: Non-blocking asynchronous execution rickman <gnuarm@gmail.com> - 2012-07-25 14:41 -0700
    Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 02:54 +0000
      Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 20:48 -0700
  Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-25 16:57 -0700
    Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 17:22 -0700
      Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-25 18:22 -0700
        Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 03:03 +0000
          Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-26 00:59 -0700
            Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 08:27 +0000
              Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-26 11:02 -0700
                Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-27 05:09 +0000
        Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-27 00:03 -0700
          Re: Non-blocking asynchronous execution Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-27 11:55 +0000
  Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 17:48 -0700
    Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 02:44 +0000
      Re: Non-blocking asynchronous execution "Elizabeth D. Rather" <erather@forth.com> - 2012-07-25 17:26 -1000
        Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-27 05:23 +0000
          Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-26 23:24 -0700
      Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 20:56 -0700
        Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 08:21 +0000
          Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-26 13:43 -0700
            Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-27 04:40 +0000
              Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-26 23:10 -0700
  Re: Non-blocking asynchronous execution jim@rainbarrel.com - 2012-07-27 10:41 -0700

csiph-web