Fork doesn't create threads, it creats processes.
What you want to use is pthreads.
Check out the pthread_create man page for information on how to get started here... but feel free to ask any specific questions you have once you get stared. Remember, you have to add the -lpthread option to gcc to get threaded code to compile.
Threads share memory space, so all your threads will be able to see your global variables. Keep in mind that if you have a reader thread and a writer thread you probably want to implement locking on your data structure so you don't get partial reads.
Last edited by jtshaw; 06-13-2005 at 07:17 AM.
|