Skip to content

Multi-threading & appropriating/reinventing PAUSE, ENTRY, STOP, CALL, RETURN for use with it. #235

@LydiaMarieWilliamson

Description

@LydiaMarieWilliamson

Adding the simplest multi-threading primitives that can be conceived, that would also happen to bring us one step closer to a bona fide implementation of the PI-calculus.

(0A) Thread-local variables & declarations (a prerequisite to what follows).
(0B) A "channel" descriptor type; similar to the "unit" descriptor type used with files.

(1) Spawning new threads.
SPAWN Function / Subroutine - works like a function or subroutine call, except it starts and runs in a new thread on its own thread-local space.

(2) Exiting a thread
STOP - now appropriated to serve as a routine that removes the thread's locals and stack and space, and ends execution.
RETURN - treated as equivalent to STOP, when the return takes place at the top level of a thread.

(3) Pausing
PAUSE Channel IOList
Stops the thread, to await activation from elsewhere (either from another thread, an exception or interrupt).
Expects values to be assigned to the variables by whoever reactivates the thread.

A routine may have multiple calls to PAUSE within it; each of them being treated as a separate entry point to the routine.
The multiple entry point facility in Fortran is appropriated for reuse in this new capacity.

The READ statement may also be used as equivalent to a PAUSE, when the read is done on a Channel.

The ENTRY statement is appropriated for reuse as a call to PAUSE.

(4) Resuming
RESUME Channel IOList
Resumes whatever thread is waiting on the given Channel and sends it the indicated value(s).

A WRITE statement may also be used as equivalent to RESUME, when the write is done on a Channel.

A CALL on an ENTRY point is appropriated for reuse as a call to RESUME.

(5) Appropriating CALL and RETURN
A semantic equivalence is mandated of the form:
(a) A CALL to a function or routine X is treated as equivalent to a spawn on X, followed immediately by a PAUSE on a fictitous channel X_C, as if the function were a separate thread, which the calling thread is then set to wait on.
(b) A RETURN from within a function or routine X is treated as equivalent to a resume on X_C, followed immediately by a STOP, as if the function's "thread" were eliminated, after the calling thread is resumed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Clause 11Standard Clause 11: Execution control

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions