Subj : Re: redundant functions - beginner To : comp.programming.threads From : Ulrich Eckhardt Date : Sat Mar 19 2005 10:49 am Pasacco wrote: > Regarding parameter passing, when we send (pointer of) multiple arrays > to thread function, we have to pass (pointer of) the structure, if this > is correct. > > My preliminary program looks like below ; we have initially 8 arrays > and I am doing some permutations (and sorting, etc) for each array. The > code size became is too big, compared to sequential program. It seems > inefficient, because we have to pass the whole structure to each thread > function. In case this is not a good program, let me know why, how can > we solve this...:) Would have been nice telling us what programming language you are using... > struct par{ > int *a0, *a1, *a2, *a3, *a4, *a5, *a6, *a7; // 8 arrays > int *a0N,*a1N,*a2N,*a3N,*a4N,*a5N,*a6N,*a7N; // size of each > }arrays; Ok...looks like C. Firstly, this thing starts with a lie: there is no array, just pointers. Further, imagine expanding this to 4962 elements. Not an attractive thought, right? Therefore: struct int_vector { int* elements; size_t count; }; struct int_vector array[4962]; Now, second thing is that you declare this data global. IOW, there is absolutely no need to pass any pointer at all to the thread function, you could as well use the global directly. Anyhow, using above function, you can pass a selected array only to the function, possibly using a proxy-struct or array to pass several of them through a single void*. Lastly, where is your question about threads? Seriously, your problem is rather how to use C efficiently and elegantly, so I'd consider taking this to comp.lang.c or alt.comp.lang.learn.c-c++. Uli .