[comp.lang.prolog] Process Control in Prolog

pling@88opensi.UUCP (Paul Ling) (02/22/90)

Hello,

Question : 
	How can I do process control in Prolog ?

For example, I would like to implement the following:

	1. Parent process fork a child process
	2. Parent process wait for a condition is set
	3. Child finishes and set the condition
	4. Child exits
	5. Parent continues.


Thanks in advance.

(By the way, this is not my homework)

				Paul Ling
				uunet!88opensi!pling or
				uunet.uu.net!88opensi!pling

ok@goanna.oz.au (Richard O'keefe) (02/23/90)

In article <378@88opensi.UUCP>, pling@88opensi.UUCP (Paul Ling) writes:
> Question : 
> 	How can I do process control in Prolog?
> For example, I would like to implement the following:
> 	1. Parent process forks a child process
> 	2. Parent process waits for a condition to be set
> 	3. Child finishes and sets the condition
> 	4. Child exits
> 	5. Parent continues.

The sequence of steps described above is no more and no less than
a procedure call.  You only need multiple processes when the parent
must continue while the child is still running.  UNIX programs
typically use "fork" simply to get a new address space; other
operating systems (AEGIS, Multics, B6700/MCP, Lilith) allow a
program to be "called" in the same address space.

Many Prolog systems provide a built in command called system/1,
or something like that, so you could do
	system('prog arg')
	unix(system('prog arg'))
	sh('prog arg')
or something similar.  NU Prolog provides 'fork' and 'wait' as
built in commands; Prologs with a C interface let you add them
easily, and Prologs-with-source like C Prolog and SB Prolog also
let you add them easily.

If you want multi-threading where parent and child processes are
both Prolog, and more than that, share the same address space,
there are some extensions to Prolog around which will let you do
it, but it's not very common (yet).

What are you really trying to accomplish?

mmh@cs.qmw.ac.uk (Matthew Huntbach) (02/27/90)

In article <378@88opensi.UUCP> pling@88opensi.UUCP (Paul Ling) writes:
>
>Hello,
>
>Question :
>       How can I do process control in Prolog ?
>
Don't do it in Prolog, do it in Parlog or one of the other
concurrent logic languages. See, e.g. Ringwood's paper
"Parlog-86 and the Dining Logicians" CACM 31,1 - Jan. 1988

or Shapiro and Takeuchi's "Object-Oriented Processing in
Concurrent Prolog", New Generation Computing, 1,1 1983

or mail me for a few unpublished papers I'm working on.

Matthew Huntbach