Global description of the project
The
project
we are describing here has many similarities with the
W3Kit Object Library,
in that it focuses on using WWW as a highly portable remote
display interface. The first goal of the project is to make the book
used in our department's Data Structure class available on-line in
hypertextual form,
to make it easier for the students to browse through it.
The second goal of the project is to make it
possible for the students to activate the execution of
the algorithms described in the book, and to control the
execution of these algorithms through some sort of control
panel, as with a symbolic debugger.
The specification and the implementation of the system necessary
for the project has been given as an assignment to the
Software Engineering class, as a semester project.
What is presented here is thus the result of a collaborative effort
and shouldn't be considered the work of just the author of this
document.
WWW was chosen as a support system for this project as it
allows for remote access and provides a highly portable
display interface abstraction. This includes the Mosaic
viewer, as the system we have implemented makes heavy use of
forms
as they are implemented since
version 2.0 of Mosaic for X.
This approach should make it easy for a student to use
this on-line facility from any personal computer or
workstation on campus, or even anywhere else in the Internet world.
Since the book was available in electronic form, putting it
in hypertextual form was not much of a problem and will therefore
not be discussed in this paper. The main problem that had to be
solved was to monitor the execution of Pascal programs through
WWW, taking into account the fact that the http protocol is
stateless, that is, the server does not remember former
queries when it processes a new one (see
note).
This problem can be further decomposed into:
- How to run a WWW-activated program step by step.
- How to display the intermediate states of the program,
including its data structures.
- How to manage user interactions with the model to view or modify
the content of variables or set breakpoints in the code.
- How to minimize client-server traffic.
A few solutions were considered to allow the execution of
Pascal programs from within an
HTML
document.
- First, we considered using a Pascal interpreter and modifying it
to allow external monitoring of its states. This solution was
abandoned, as we had available only a Pascal-S interpreter, that
didn't include file I/O nor dynamic allocation (no pointer types).
In other circumstances, using an interpreter could however be a
viable solution. Actually, many http servers are already written
in some interpreted language. For instance, the
Plexus server
is just a
Perl
script.
- We then considered rewriting every Pascal program as a finite state
automaton that could start execution at any state and stop
execution either at the next state, or at any state for which
there would be a breakpoint. The program state and data
would be transmitted to the WWW client, both as text to be displayed
and, in a more compact form, as a URL hidden in a
hyperlink associated with the Step and Continue
push-buttons (see pseudo-code).
As an alternative to transmitting the whole program data from the
server to the client, than back to the server, this information
could be stored on the server side, in a temporary file, and have
the URL hold a reference to this file.
This solution would however not be easy to implement for recursive
algorithms, as it would imply the explicit management of a stack to store
local variables and parameters.
- The solution we finally chose consists in having the shell script,
invoked by the http server,
spawn a child process to run a slightly modified version of
the Pascal program. The modification consists in adding, between
each original Pascal instruction, a call to a synchronization procedure.
The synchronization procedure checks whether the
execution of the Pascal program should continue, or be interrupted.
Whenever there is a breakpoint on the current instruction,
or when the user has selected the single step button,
the current state is sent to the client viewer, and the
synchronization procedure
waits for a signal from the server-activated shell script
to resume execution, with possibly new breakpoints and
selected variables, based on the latest user request.
This is a section of a local copy of the paper
World-Wide algorithm animation
by
Bertrand Ibrahim.
Site Hosting: Bronco