Posted: Mon Jan 30, 2006 6:45 pm Post subject: is there a way to exit a fork.
is there a way to exit a fork?
Sponsor Sponsor
Delos
Posted: Mon Jan 30, 2006 7:32 pm Post subject: (No subject)
Several possibilities:
- Don't use processes. They're not well handled in Turing and require a great deal of skill to pull off.
- If you must, I'm guessing that the one in question has a loop in it. You could create an exit condition that would be satisfied by a global variable, that could be changed by another proc.
- Look into wait, signal, and possibly monitor. AFAIK, there are no tuts available for these, since they are so rarely used (as we try to discourage the use of processes as much as possible, for the above mentioned reasons).
Martin
Posted: Mon Jan 30, 2006 7:33 pm Post subject: (No subject)
It'll exit whenever the process is finished running.
code:
var killProcess : boolean := false
process myProcess
loop
exit when killProcess
put "process!"
end loop
end process
fork myProcess
delay (2000)
killProcess := true
But yeah, using processes is a bad idea - they will result in you having bad and slow code that is difficult to debug.
redrenagade
Posted: Thu Feb 02, 2006 4:54 pm Post subject: (No subject)
You would always try to declare a string type variable.
Then in the loop within the process, type "exit when string_variable := " stop". Then, when u want the process to stop, simply have a line of code that looks like this:
string_variable := "stop"
This should stop the process effectively, atleast it did for my program anyway.
Cervantes
Posted: Thu Feb 02, 2006 6:04 pm Post subject: (No subject)
redrenagade wrote:
Then in the loop within the process, type "exit when string_variable := " stop".
Except, Turing uses "=" for comparison, and ":=" for assignment.