[Oberon] threads

Søren Renner soren.renner at gmail.com
Tue Sep 19 23:16:56 CEST 2006


thank you mr frey! with careful use of BEGIN{EXCLUSIVE}....END, the
kernel errors have disappeared. there remains some difficulty however.
to sketch:

there is an active process which drives the renderer. each frame, it
handles the mouse and keyboard inputs, moves the camera, prepares the
rays (one per pixel), and so forth. then it calls the ray engine. the
ray engine is a module that has n tiles. each tile traces the rays for
a piece of the window. the tiles have active bodies. The problem is,
how to arrange things so that "go" only returns when all the tiles are
done, and each tile only works once. should the following work?

MODULE rayengine;

TYPE tile=OBJECT;
VAR
     I:INTEGER;

PROCEDURE&init(i:INTEGER)
BEGIN
   I:=i
END init;

BEGIN{ACTIVE}
     REPEAT
          BEGIN{EXCLUSIVE}
               AWAIT(tilego[i])
               tilego[i]:=FALSE;
               TRACE RAYS
               INC(tilesdone);
           END
     UNTIL FALSE
END;

VAR
   tiles: ARRAY n OF tile;
   i, tilesdone: INTEGER;
   tilego: ARRAY n  OF BOOLEAN;

PROCEDURE frame*;
BEGIN
     BEGIN{EXCLUSIVE}
          tilesdone:=0;
          FOR i:=0 TO n-1 DO
              tilego[i]:=TRUE;
          END;
     END;
     DebugLog.String("Frame started");
     BEGIN{EXCLUSIVE}
          AWAIT(tilesdone=n)
     END;
     DebugLog.String("Frame done");
END go;

BEGIN
     FOR i:=0 TO n-1 DO
         NEW(tile[n],i)
     END
END rayengine;


More information about the Oberon mailing list