Subj : Re: mechanism of threads... To : comp.programming.threads From : Paul Pluzhnikov Date : Sat Feb 26 2005 01:22 pm "Mozis" writes: [Please capitalize first letter of the word that begins a sentence. Learning to spell would not hurt either.] > now process address space consist of ... > now which part of this address space is shared with thread? All of it. > Now the programming mechanism of thread is somewhat as follows, > call to pthread_create(id,attr,fuc-pointer,args) > now when a thread is created the apprpriate function is called thru > that func-pointer right. then how come v say that thread is running in Who is 'v' ? > parent address space because the programme code is diffrent in that > function body then wat it would be in parent. It isn't different. Here are two ways to call function func(), and they are exactly equivalent (though one is more efficient then the other): void *func(void *p) { ... } int main() { int x; pthread_t tid; void *result = func(&x); /* one way */ pthread_create(&tid, 0, func, &x); /* the other way */ pthread_join(tid, &result); /* end of the other way */ return 0; } > Now another confusion is suppose if we have forked multiple processes > then would the all share the global memory or get a unique copy of > that? The processes do not share "global memory", unless you specifically arrange for them to do so (man shmat). > last but not least, is ther any difference between heap memory and wat > we say global memoey.. Yes. The global memory (initialized and BSS data) is "present" before the first instructions of your program are executed. For the heap memory to appear, you must ask the OS to give it to you (man sbrk, man malloc, man mmap). Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email. .