Linux的pthread_suspend [英] linux pthread_suspend

查看:786
本文介绍了Linux的pthread_suspend的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来像Linux的犯规实施pthread_suspend继续,但我真的需要他们。

Looks like linux doesnt implement pthread_suspend and continue, but I really need em.

我都试过cond_wait,但实在是太慢了。这项工作正在螺纹大多在50us的执行,但偶尔向上执行500毫秒。与cond_wait问题是双重的。互斥锁正在可比的时间到微秒处决和我不需要锁定。其次,我有很多工作线程和我真的不希望使N条件变量的时候,他们需要被唤醒。

I have tried cond_wait, but it is too slow. The work being threaded mostly executes in 50us but occasionally executes upwards of 500ms. The problem with cond_wait is two-fold. The mutex locking is taking comparable times to the micro second executions and I don't need locking. Second, I have many worker threads and I don't really want to make N condition variables when they need to be woken up.

我确切地知道哪些线程正在等待它的工作,可以只pthread_continue该线程。线程知道当没有更多的工作,并且可以容易地pthread_suspend本身。这将不使用锁定,避免踩踏,并会更快。问题是....没有pthread_suspend或_continue。

I know exactly which thread is waiting for which work and could just pthread_continue that thread. A thread knows when there is no more work and can easily pthread_suspend itself. This would use no locking, avoid the stampede, and be faster. Problem is....no pthread_suspend or _continue.

任何想法?

推荐答案

请在线程等待一个特定的信号。

Make the thread wait for a specific signal.

使用 pthread_sigmask 并的 调用sigwait

Use pthread_sigmask and sigwait.

这篇关于Linux的pthread_suspend的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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