Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 11/03/84 (WLS Mods); site astrovax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!astrovax!wls From: wls@astrovax.UUCP (William L. Sebok) Newsgroups: net.lang.forth Subject: Re: Forth for Sys V (VAX or Mega-Frame)? (somewhat long reply) Message-ID: <609@astrovax.UUCP> Date: Thu, 30-May-85 23:30:40 EDT Article-I.D.: astrovax.609 Posted: Thu May 30 23:30:40 1985 Date-Received: Fri, 31-May-85 23:49:22 EDT References: <1692@bmcg.UUCP> Organization: Princeton Univ. Astrophysics Lines: 76 > I am looking for a Forth which will run on a VAX 11/780 under > System 5.2 or a Forth which will run on a Burroughs XE-550 > (a.k.a. Convergent Technology Mega-Frame.) I had a copy of > Kitt Peak Forth running, but that was under 4.1 BSD. > (Anyone out there of the wizard persuasion - is it feasible to > run the Kitt Peak version under our new Sys V?) > Thanks for any and all help. > > P.s. Where is Bill Sebok when we need him? > Larry J. Huntley Burroughs -(B)- Corporation I'm still here. I've just been too buried to follow the discussion much except sporadically. I have no access to a System 5.2 VAX so I have not been able to add the #ifdef's to my Forth to run under such a system. I don't think it would be all that hard. If somebody with a System 5.2 VAX reasonably close to Princeton would give me an account on their machine I might be tempted to try it. I intend to post version 3.0 of Princeton Forth for the VAX 4.X BSD sometime near the end of the summer. New goodies are being added. The main one being added at the moment is dynamic subroutine loading. This lets you load subroutines written in some other language into Forth memory and execute them as Forth words. I am talking about this (mainly the pitfalls encountered) at the upcoming Forth conference in Rochester. Princeton Forth, by the way, is another Forth that compiles directly into machine language rather than address threaded code (personally I think that is the only way to go on the VAX). It has been around since 1982 and is used here for image processing where speed is the name of the game. Some of its characteristics include separate stacks for strings and floating point quantities. The main thing that I am happy to report is that I have solved the problem of allowing the C routine malloc() to coexist with Forth memory layout. malloc() is called by many C (and Fortran and Pascal) routines and especially is called by the ubiquitous stdio routines. I've solved the problem in a way that imposes no new restrictions on either Forth or the non-Forth subroutine. The modifications are mainly to FORGET with minor ones to malloc(). Since I have written my own version of malloc() I can include the suitably modified version of it in my next Forth posting. This version, of malloc() is, by the way, I think superior to either 4.2 BSD's or the original 4.1 BSD's and I have intended to post it on its own if I ever got around to documenting it. The problem occurs when malloc() is called and then a FORGET is issued. Suppose pointers to the malloc'ed memory are saved somewhere in the memory of the calling subroutine. These pointers are no longer valid after a FORGET. Attempts to use these pointers will cause an illegal memory access. The issue is made hard if one wants to use standard library routines which are unaware of Forth's use of memory. The problem has been solved in this way: A call to free() which frees memory adjacent to the dictionary pointer will cause the dictionary pointer to be moved back to the beginning of the area freed. A call to malloc() which cannot be satisfied from existing free areas causes the dictionary pointer to be advanced. If a FORGET is issued and the memory to be forgotten contains one or more areas allocated by malloc() and not free()ed then in addition to its usual actions FORGET takes these actions: 1) The dictionary pointer is moved back to the end of the last area allocated by malloc(). 2) The areas of memory that are above the FORGET point but are between the malloc() allocated memory areas are marked "free" as if they had been freed by the library free() routine. Thus this memory will be the first memory reused by further calls to malloc(). The net effect of all of this is that malloc(), free() and normal dictionary growth and FORGETing can co-exist in the same memory, without the necessity of pre-allocation of fixed size areas of memory to either malloc() or to dictionary growth. -- Bill Sebok Princeton University, Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls