Diff for /gforth/tasker.fs between versions 1.1 and 1.8

version 1.1, 1996/03/31 20:16:04 version 1.8, 2000/09/23 15:46:59
Line 1 Line 1
 \ Multitasker                                          19aug94py  \ Multitasker                                          19aug94py
   
   \ Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
   
   \ This file is part of Gforth.
   
   \ Gforth is free software; you can redistribute it and/or
   \ modify it under the terms of the GNU General Public License
   \ as published by the Free Software Foundation; either version 2
   \ of the License, or (at your option) any later version.
   
   \ This program is distributed in the hope that it will be useful,
   \ but WITHOUT ANY WARRANTY; without even the implied warranty of
   \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   \ GNU General Public License for more details.
   
   \ You should have received a copy of the GNU General Public License
   \ along with this program; if not, write to the Free Software
   \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   
 Create sleepers  sleepers A, sleepers A, 0 ,  Create sleepers  sleepers A, sleepers A, 0 ,
   
 \ LINK-TASK links task1 into the task chain of task2  \ LINK-TASK links task1 into the task chain of task2
Line 23  Create sleepers  sleepers A, sleepers A, Line 41  Create sleepers  sleepers A, sleepers A,
   lp! fp! rp! prev-task @ sleep ;    lp! fp! rp! prev-task @ sleep ;
   
 \ USER' computes the task offset  \ USER' computes the task offset
 : user' ( 'user' -- n )  :noname    ' >body @ ;
   ' >body @ state @ IF  postpone Literal  THEN ; immediate  :noname    ' >body @ postpone literal ; 
   interpret/compile: user' ( 'user' -- n )
   
 \ NEWTASK creates a new, sleeping task  \ NEWTASK creates a new, sleeping task
 : NewTask ( n -- Task )  dup 2* 2* udp @ + dup  : NewTask ( n -- Task )  dup 2* 2* udp @ + dup
   allocate throw  + >r    allocate throw  + >r
   r@ over - udp @ - next-task over udp @ move    r@ over - udp @ - next-task over udp @ move
   r> over user' r0 + ! dup >r    r> over user' rp0 + ! dup >r
   dup r@ user' l0   + ! over -    dup r@ user' lp0   + ! over -
   dup r@ user' f0   + ! over -    dup r@ user' fp0   + ! over -
   dup r@ user' s0   + ! over -    dup r@ user' sp0   + ! over -
   dup r@ user' normal-dp + dup >r !    dup r@ user' normal-dp + dup >r !
    r> r@ user' dpp  + ! + $10 +     r> r@ user' dpp  + ! + $10 +
       r@ user' >tib + !        r@ user' >tib + !
Line 45  Create sleepers  sleepers A, sleepers A, Line 64  Create sleepers  sleepers A, sleepers A,
   
 : (pass) ( x1 .. xn n task -- )  rdrop  : (pass) ( x1 .. xn n task -- )  rdrop
   [ ' kill-task >body ] ALiteral r>    [ ' kill-task >body ] ALiteral r>
   rot >r r@ user' r0 + @ 2 cells - dup >r 2!    rot >r r@ user' rp0 + @ 2 cells - dup >r 2!
   r>              swap 1+    r>              swap 1+
   r@ user' f0 + @ swap 1+    r@ user' fp0 + @ swap 1+
   r@ user' l0 + @ swap 1+    r@ user' lp0 + @ swap 1+
   cells r@ user' s0 + @ tuck swap - dup r@ user' save-task + !    cells r@ user' sp0 + @ tuck swap - dup r@ user' save-task + !
   ?DO  I !  cell  +LOOP  r> wake ;    ?DO  I !  cell  +LOOP  r> wake ;
   
 : activate ( task -- )  0 swap (pass) ;  : activate ( task -- )  0 swap (pass) ;
 : pass ( x1 .. xn n task -- )  (pass) ;  : pass ( x1 .. xn n task -- )  (pass) ;
   
 : task-key   BEGIN  pause key?  UNTIL  (key) ;  : single-tasking? ( -- flag )
       next-task dup @ = ;
   
   : task-key   BEGIN  pause key? single-tasking? or  UNTIL  (key) ;
 : task-emit  (emit) pause ;  : task-emit  (emit) pause ;
 : task-type  (type) pause ;  : task-type  (type) pause ;
   

Removed from v.1.1  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>