|
-
September 30th, 2005, 01:35 PM
#11
The real difference between a process fork and a thread if the use of memory. Threads all have their own stack, but share a heap. New processes on the other hand don't share a heap or stack. Fork is the way this was done in the past, and threads is the newer way of doing things that make programming easier. Most of the same functionality can be accomplished in either case.
What you really need is most likely what Katja described, just a simple for( ; ; ) loop that checks for conditions and branches based on those conditions. You cannot do multiple instructions at the same time (unless its an atomic operation), but you can repeatedly check for one condition and then the other.
The use of multiple threads in your application does increase the risks of bugs in your code, some of which that can be real nasty. The most common error is when two threads are writing data to the same memory location. Or one is reading while the other is writing to some memlory location. This results in corrupt data that can crash your application.
Threads and multiprocesses can definately create bugs, but its a little more complicated that just reading and writting. The issues you'll run into will be deadlock and race conditions. Usage of semophores, locks, and structured variable requests will alleviate these issues.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|