Seppo Mustonen : Programming Survo in C

2. SURVO 84C processes

The term process is described in the Microsoft C run-time library reference as follows (p.73):

The term "process" refers to a program being executed by the operating system. A process consists of the program's code and data, plus information pertaining to the status of the process, such as the number of open files. Whenever you execute a program at the MS-DOS level, you start a process. In addition you can start, stop, and manage processes from within a program by using the process control routines.

The possibility to start up another process during the program as a `child' process is crucial in the construction of SURVO 84C. There are a few alternatives for calling child processes. The new process may overlay the parent process or the parent process may stay resident during the child's execution. Both alternatives are used in SURVO 84C, and in most cases the latter one, since the main program remains always resident until the end of the session.

As a consequence of this construction principle, we can always call other programs easily while staying in SURVO 84C in the same way as SURVO 84C calls its children. The only provision is that there is enough memory left for the new process and it can be accessed from the current directory (of SURVO 84C). Thus all MS-DOS commands may be given like any SURVO 84C command directly from the edit field by putting the `prompt' symbol `>' before the command and by activating it like a SURVO 84C operation. For example, >DIR A:*.EDT lists all edit files on disk A:.
     Similarly we can start any executable program (.EXE or .COM) or batch file (.BAT) during the SURVO 84C session. For example, >S always starts a new SURVO 84C copy as a child of the current one (since S.EXE is the main program of SURVO 84C). Upon returning from child S we are back in the original SURVO 84C session.

Hence most programs without modifications may serve the SURVO 84C system as its child processes. This is very helpful for experienced users, since they can employ SURVO 84C as a natural extension of the operating system and do everything while staying in SURVO 84C.
     However, to make a program a true SURVO 84C module some considerations related to input and output should be taken into account. Also the general requirements and the style of SURVO 84C programming may imply modifications in existing programs.
     A formal distinction between a SURVO 84C module and a general program is that the file names of directly callable SURVO 84C modules start with `!'. Furthermore, the SURVO 84C modules receive all the input information directly from the main program (editor) so that they cannot be executed alone.

The link between the main program and a module is one address given by the main program as a parameter and pointing to an array of pointers. This array tells the addresses of the SURVO 84C system parameters and variables so that the module may use the same information as the main program does. Then, from the programmer's point of view, the module is an integrated part of the main program. For real access to those parameters and variables, the module has to call first an initiation function (s_init).
     During its work, the module may update various system variables (for example, write results in the edit field) so that the effects of the module can be seen immediately after returning to the main program.
     The cooperation between the main program and the modules strengthens the system. The system is more than a collection of different programs. Therefore it is important to take full advantage of these possibilities for interaction when creating new modules.

Previous: Introduction
Next: Example of a SURVO 84C module

Front page of Programming Survo in C