merge sorting usnig process

May 15, 2009 at 5:04am
Hello all...
how can i implement merge sort using process in linux? i know fork should be used to create process.but how can i control the child process to work with array passing some kinds(actually i don't know)parameter to it?
Thanks in advance
May 15, 2009 at 1:34pm
closed account (S6k9GNh0)
Why are italics needed on every word...

Anyways, I suggest you google the exact heading you used for this topic. You'll get results.
Last edited on May 15, 2009 at 1:35pm
May 15, 2009 at 3:48pm
Why do you want to use child processes to do the merge?
May 15, 2009 at 4:43pm
will a thread do rather than creating a process??
May 16, 2009 at 3:26pm
Actually a process will create two child processes each having half of the array element...recursively a function will be called to do this..after completion of recursion two child process will return the array element to their mother process and it will sort those two arrays....is it possible??how??
May 17, 2009 at 5:19am
what you want to do can be effectively done by threads.. but if you want to create process for that then you need a way for communication between the processes..like shared memory, memory mapped files or IPC. read about them.
May 18, 2009 at 1:20pm
I think you are looking for this:

std::stable_sort(my_data.begin(), my_data.end());


Then you just have to trust the compiler to do right think.

For gcc and libstdc++ you can use parallel mode: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch31s03.html
Topic archived. No new replies allowed.