C ++多线程-与线程合并排序的算法替代 [英] C++ Multithreading - algorithm alternative of merge sort with threads

查看:106
本文介绍了C ++多线程-与线程合并排序的算法替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一种合并排序算法,该算法对具有整数数据的数组进行排序.

I have written a merge sort algorithm that sort array with integer data.

现在,我需要使用多线程概念-phthread再次编写另一种排序算法,该算法再次使用整数数据对数组进行排序.

Now I need to write another sorting algorithm again with multithread concepts -phthread, which again sorting array with integer data.

我的任务背景: 我有2个子进程,它们对(一个不同的算法)排序一个整数数组,并首先完成任务打印结果,而父进程则杀死了另一个进程.我已经完成了实现第二算法逻辑所需的一切

My task background: I have 2 child processes which sorting(with different algorithms) one integer array and first completed task print result and parent kill another process. I had done everything just need to implement 2nd algorithm logic

请告诉我我必须使用哪种算法,并给我一个示例实现

Please tell me which algorithm I have to use and give me an example implementation

提前谢谢

推荐答案

一个可移植的选择是使用

One portable option is to use Intel Parallel STL. It is compatible with C++11 and implements parallel std::sort.

GNU C ++标准库中的C ++ 17并行算法和gcc-9委托给Intel Parallel STL.

C++17 parallel algorithms in GNU C++ standard library and gcc-9 delegate to Intel Parallel STL.

这篇关于C ++多线程-与线程合并排序的算法替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆