[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Apr 11 08:40:28 1999 
Subject:Re: Queues in POP11 
From:Aaron Sloman See text for reply address 
Volume-ID:990411.01 

"Jonathan L Cunningham" <jlc@sofluc.demon.co.uk.spam> writes
regarding LIB QUEUE:

> Date: Wed, 7 Apr 1999 19:09:20 +0100
>
> Thanx. I wonder if anyone else (apart from me) has used it in
> the last 15 years? (Actually, I know they have, since it was
> actually written as a library which is called from another
> library I know *was* used.)
>
> Jonathan
>

It was used in LIB ACTOR, written by yourself, which was also used
in LIB ACTOR_EVENT.

To make you feel nostalgic, I append a slightly abbreviated version
of the help file (most of the definitions have been truncated here).

I should put some of these facilities intothe sim_agent toolkit,
which has some similar aims, though it would be easy for users to
do.

It allows each actor (nowadays the fashion is to call them "agents")
to have within it a collection of concurrent processes each
implemented using a forward chaining production system interpreter
(poprulebase). I think I may have got some of the ideas for this
framework from some of your work, and conversations we had during
the Uide project.

Aaron

Help file follows. Apologies to those who get this via the email
gateway. Delete the rest of the file if you have poplog and can read
HELP ACTOR

===================================================================
HELP ACTOR                                           J L Cunningham 1982
                                              Revised John Gibson Aug 93

------------------------------ NOTE ------------------------------------

  From Version 14.5, a change has been made to LIB * ACTOR which makes
  it incompatible with previous versions: the new version has all the
  exported (i.e. top-level) identifiers prefixed by "actor_". In
  addition, LIB EVENT has been replaced by LIB * ACTOR_EVENT, with
  a similar renaming of identifiers.
------------------------------------------------------------------------

The library ACTOR uses the Pop-11 *PROCESS facility to implement basic
procedures for a discrete event simulation package. This can be used for
multi-tasking.

In addition, LIB * ACTOR_EVENT provides an event-handler and associated
procedures, which are described in this help file.

The main user procedures and variables and the terminology used are
described now; the end of this file contains a list of all the other
important global variables and procedures, with a brief description of
what they do.

ACTIVE      At any one moment of real time, only one ACTOR program can
            actually be running (since Pop is a serial language.) Here,
            though, all ACTORs which may become CURRENT without the
            intervention of another ACTOR are referred to as ACTIVE
            (this is not quite standard usage). Basically the ACTIVE
            ACTORs are those that are WAITING plus the CURRENT ACTOR.
            The other actors (those SLEEPING or waiting for an EVENT
            (see ACTOR_WAITEVENT) or waiting to ACTOR_RECEIVE a MESSAGE,
            are not ACTIVE.

ACTOR       When a simulation is started, there will be a number of
            independent (but possibly communicating) "programs" running,
            and possibly multiple copies of the same program. These
            entities are referred to as ACTORS. (An actor is actually
            represented as a RECORD (see HELP *DEFCLASS), one of whose
            components is a pop PROCESS.) In order for actors to
            interact, they each have a name, (see ACTOR_MYNAME) which
            should be unique to that actor.

actor_apocalypse();
            This procedure is run as the final EVENT of a simulation at
            time ACTOR_AEONS.

actor_askactor(<name>,<question>) -> <answer>;
            Runs the named actor's ACTOR_ANSWER procedure, to obtain the
            answer to <question>, but in the context of the <name>d
            actor.

actor_answer(<question>) -> <answer>;
            This procedure, which should normally be local to individual
            actors, will be run if the actor is asked a <question> by
            another actor.
                            ..................... While
            running ACTOR_ANSWER, all local variables will be as they
            were when the actor answering the question became
            non-CURRENT. Also, CURRENT temporarily becomes the answerer.

actor_aeons
            This constant corresponds to the end of time. It is a large
            number.

CURRENT     The actor currently running is described as CURRENT.

DEBUG       If the pop procedure *POPREADY is included as one of the
            actors at ACTOR_GENESIS, then it can be used for debugging
            purposes.

actor_die();
            The current actor dies. An actor also dies if the procedure
            which is called when the actor starts returns normally. (If
            ACTOR_DIE is used the actor could be reincarnated if it had
            been saved somewhere; however if the current actor's
            procedure returns normally, it is very dead and cannot be
            reincarnated.)

actor_diewhen(<event>);
            This procedure is in LIB ACTOR_EVENT, and can only be used
            when there is an ACTOR_EVENTHANDLER. It causes the actor
            which calls it to be KILLed when the named <event> (or one
            of the events in the list - cf ACTOR_WAITEVENT) occurs.

EVENT       This word has two meanings. Firstly, every time anything
            occurs, that is an event. Thus, if an actor has WAITed for a
            period (of simulated time), and then it does something, that
            something is an event (cf APOCALYPSE). However, there is a
            more restricted meaning, reserved for particular events
            notified to the ACTOR_EVENTHANDLER.

actor_event(<eventname>,<message>);
            This procedure is in LIB ACTOR_EVENT. If the event
            <eventname> has occurred then this procedure should be
            called, and the ACTOR_EVENTHANDLER will send the <message>
            to any other actors waiting for the event <eventname> (see
            ACTOR_WAITEVENT).

actor_eventhandler();
            This procedure is in LIB ACTOR_EVENT. If the procedures
            ACTOR_EVENT and ACTOR_WAITEVENT are to be used, then the
            word "actor_eventhandler" should be included in the
            ACTOR_GENESIS argument, so that it will be used for an actor
            called "eventhandler1".

actor_exists(<name>);
            Returns true if <name> is NAMEOF an existing actor,
            excluding the current actor. (i.e. in WAITING or SLEEPING).

actor_genesis(<initial>);
            This procedure is used to start a simulation. ....

actor_gpo(<name>,<message>,<delay>);
            Defined as
                    actor_newactor(send,[%name,message%],delay)

actor_kill(<name>);
            Removes an actor whose NAMEOF is <name>

MESSAGE     A MESSAGE can be any Pop data structure.

actor_mymessagequeue
            This is a queue (local to each actor) of messages for the
            current actor

actor_myname
            This is a variable which is local to each actor.

actor_myparent
            This is a variable which is local to each actor.

NAME        To distinguish ACTORs, they each have a name, which should
            be unique. See ACTOR_MYNAME.

actor_newactor(<procedure>[,<actorname>][,<arglist>][,<delay>]);
            ACTOR_NEWACTOR creates a new actor. There are a variety of
            calling formats,

actor_receive() -> <message>;
            Gets the next message for the current actor. Messages are
            kept in a queue (see HELP *NEWQUEUE)....

actor_say(<something>);
            Prints <something> on a new line, preceded by the NAMEOF the
            CURRENT actor, and also the time if ACTOR_SAYTIME is TRUE.

actor_send(<name>,<message>) -> <boolean>;
            Adds <message> to <name>d actor's queue of messages, and
            WAKEs actor.

actor_simtime
            The value of this variable is the current simulation time;

actor_sleep();
            The current actor falls asleep, i.e. it becomes inactive.

actor_wait(<duration>);
            The current ACTOR waits, i.e. is suspended, for simulated
            delay given by <duration>.

actor_wake(<name>);
            Wake, i.e. make ACTIVE, the actor whose name is <name>

actor_waitevent(<event>) -> <message>;
            This procedure tells the ACTOR_EVENTHANDLER that the
            current actor is now waiting for the <event> (a word) or
            alternatively any of the events in <event> (a list of
            words).

-----------------------------------------------------------------------

Some procedures and variables used internally to the simulation package,
but which might be useful.

current     current actor
waiting     the actors active but not current
sleeping    the actors sleeping
find(<name>,<chain>);
            might be useful to a hacker, but look at the source code
nameof(<actor>);
waketime(<actor>);
            the time a waiting actor is due to become current
6~nextactor(<actor>);
            link to next actor when in a chain
processof(<actor>);
            might be useful to resume simulation, e.g. by
              resume(0,processof(<current>))
practor(<actor>);
            used to print an actor or chain of actors
schedule(<time>,<actor>);
            adds <actor> to WAITING with <time> as its waketime
parentof(<actor>);
            the NAMEOF the actor which created the <actor> (which is
            the argument to PARENTOF), or else "eldest" for actors
            created at ACTOR_GENESIS
messagequeue(<actor>);
            The queue used for storing <actor>'s unprocessed messages
returnanswer(<question>);
            This procedure is part of the question answering
            mechanism, and should not be called by actors.

See also
HELP *AUTOLOAD - on the automatic compilation of library files
HELP *NEWQUEUE - library procedure for creating queues
HELP *PROCESS  - summary of the Pop-11 PROCESS facility
HELP *POPVAL   - evaluates list items as Pop-11 code
HELP *POPREADY - invokes compiler recursively. Useful for interrupts
SHOWLIB *ACTOR - for the program code

===================================================================

Aaron
===
-- 
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (NB: Anti Spam address)
PAPERS: ftp://ftp.cs.bham.ac.uk/pub/groups/cog_affect/0-INDEX.html