[EMAIL PROTECTED] wrote:
>hi!
>
>with fork, you spawn a complete copy of the whole program and run it as
>another process, which isn't exactly multithreading.
You can call it heavyweight threads ;-)
>if you do an exec,
>you load another program (i think) and run it.
Exec replaces your current process' address space with the new executable.
>if you want to use true
>multithreading, in which only part of your program is run as a separate
>thread simultaneously with your main program, then you should use
>pthreads instead of fork or exec. i dont have a reference handy with me
>right now so i cant tell the exact syntax for using pthreads but it goes
>something like:
>
> create_pthread( <worker function>, <parameter>, <other flags>);
#include <pthread.h>
int pthread_create(pthread_t * thread, pthread_attr_t *
attr, void * (*start_routine)(void *), void * arg);
Then link with -lpthread
>the exact syntax may vary but the idea is the same. the worker function
>is the function you want to execute in a thread, the <parameter> is of
>course the parameter you want to pass to your function.
HTH,
JR
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]