September 30th, 2005 01:35 PM
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.
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.
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.
September 30th, 2005 03:36 PM
Well, at least zENGER understands what I'm saying here. Fork was the old way (and is still used quite often) and threads are a more modern way. It also depends a bit on your preferences and even more on your operating system.
Another useful link can be http://www.yolinux.com/TUTORIALS/#PROGRAMMING which is Linux-oriented and it has some good information about forks, threads and processes.
But personally, it's easier to just handle messages from a messageloop, like the 'for( ; ; ) loop' suggested by zENGER.
October 5th, 2005 08:25 AM
i m using windows..
anyways i solved that game problem using the kbhit() function..yes,u had told me about taking input from keyboard processes,only i didnt knew what it exactly meant then..