RetroForum Welcome, Guest. Please login or register.
September 07, 2010, 05:53:02 AM
Home Help Search Calendar Login Register

RetroForth Discussion  |  Older Boards  |  Development  |  Topic: Multithreading, processes. « previous next »
Pages: 1 Go Down Print
Author Topic: Multithreading, processes.  (Read 2111 times)
Cheery
Member
**

Karma: +0/-0
Offline Offline

Posts: 5


View Profile
Multithreading, processes.
« on: July 05, 2006, 11:51:40 PM »

Is there a way to make multiple threads/processes in current retroforth implementation?

If there is not, how could I possibly implement such behavior? (both with-OS and without-OS approaches appreciated. Windows&linux&native -support would be great!)
Logged
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
Re: Multithreading, processes.
« Reply #1 on: July 17, 2006, 06:14:08 AM »

The easiest way that I can think of would be to use the rf-generic port (no idea on Windows), and use one of the existing thread libraries. I have no real experience in this regard though.

About the most I've done is to use clone() to setup a task, but it is really a separate process...

Code:
loc:
  4 import clone
  here constant stack 1024 allot
  : add  stack 0 0 clone ;
  ~add
;loc alias >thread
 
0 variable runs

: t0 callback
  repeat 1 runs +! runs @ 5000000 =if ." done!" runs @ . cr ;then again
;

~t0 >thread
Logged
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
Re: Multithreading, processes.
« Reply #2 on: July 21, 2006, 01:17:07 PM »

Now with sharing of memory among threads....

Code:
1 import exit
loc:
  $100 constant CLONE_VM
  4 import clone
  here constant stack 1024 allot
  : add stack CLONE_VM 0 clone ;
  ~add
;loc alias >thread
 
0 variable runs
: t0 callback repeat 1 runs +! again ;

~t0 >thread
« Last Edit: July 21, 2006, 01:52:24 PM by Charles Childers » Logged
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
Re: Multithreading, processes.
« Reply #3 on: July 21, 2006, 01:51:17 PM »

And something similar for Windows:

Code:
loc:
 from kernel32.dll
 6 import CreateThread
 : new >r 0 1024 r> 0 0 0 CreateThread ;
 ~new
;loc alias >thread

variable runs
: t0 callback repeat 1 runs +! again ;

~t0 >thread
Logged
Pages: 1 Go Up Print 
RetroForth Discussion  |  Older Boards  |  Development  |  Topic: Multithreading, processes. « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media Valid XHTML 1.0! Valid CSS!