[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Elegant ending of processes



All,

I think it's fair to say that the termination of channel-based processes has long been a problem. Peter's paper (as I recall) suggested the idea of poison in the protocol, but that was limited by having to follow the data flow around the network; sometimes processes couldn't be reached by this data flow. More recently C++CSP and JCSP have added the idea of stateful poisoning of channels - this is nicely bi-directional and forms, I believe, a neat solution to the problem, most of the time. When you try to use a poisoned channel an exception is thrown. If you are waiting on a channel, and someone poisons the other end, you are interrupted and an exception is thrown in your process.

There is still a problem with this solution however. Consider the case where a member of a process-network is communicating with an "external" channel. External is fuzzy, so I'll use the concrete example of a C++CSP Id process (I'll call it P) waiting for input over a NET channel. Something happens in the local program that makes us want to quit - a user command let's say. The process receiving the user command poisons its channels. As all the other processes' channels get poisoned, they poison everything they can see. This keeps happening, and the poison is spread across all the channels in the program.

The process that will receive the data from our process P poisons the channel. However, this is P's OUT channel. P is currently waiting on its IN channel. P will not examine its OUT channel until it has received input on the IN channel - therefore P will not terminate until it receives data from this other networked machine - which could be a long time, or never. Clearly this isn't desireable. In this example, we could actually make P ALT between its IN channel and a special (and rather ugly) POISON channel. P, while ALTing, would be able to notice the poison on the POISON channel (which would be attached to a local process), and could terminate. However, this rather nasty solution would not hold if P was writing to the external process. In this case, the ALT would not work, and P again would not terminate until action was taken by the process on the other end of the network.

So what are the options. Obviously, forceful termination is one, but not very nice. Another option is to have a PoisonAllExternalChannels() function that would poison the external ends of all channels. In C++CSP's case, the only external channels are essentially the network channels. In other systems it may be things like GUI channels. This idea has some appeal, but I'm not sure about the runtime tapping into the channels, and also there are issues of which processes should be allowed to call such a powerful function - I could see the potential for over-use.

I thought I'd post this to the mailing lists because I think it is an issue that concerns all CSP-like systems, and I would be interested to hear other people's thoughts on the matter. I'm rather hoping there may be a nice solution that I haven't spotted!

Thanks,

Neil.