Subject:
|
Re: I need a little help with understanding processes
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 10 Feb 1999 02:50:18 GMT
|
Original-From:
|
Max Davies <mdavies@CAM.^nomorespam^ORG>
|
Viewed:
|
1111 times
|
| |
| |
The most common problem many people have regarding processes is that they
incorrectly assume you should call start_process repeatedly in order to
keep a background process running.
This is completely wrong, and it will crash the system one way or another.
You should call start_process only once for any one background process that
you want to run. When you start a subroutine with start_process, that
subroutine will start running completely independently of your main
program, or in other words, execution will continue immediately with
whatever follows your start_process call while the subroutine runs on its
own at the same time. Typically a routine designed to be called by
start_process will contain an endless loop, which is just fine providing
that you only do a start_process on it only once.
If you call start_process for the same subroutine a second time before the
first subroutine ends you will end up having 2 copies of the same
subroutine running at the same time along with your main program. If your
main program continues calling start_process repeatedly you will get
hundreds of copies of the subroutine running at the same time until
eventually (within a few seconds) the system will crash, normally with a
stack overflow error, although just about anything else could be possible
depending on the specifics of your program.
|
|
Message is in Reply To:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|