English 中文(简体)
多生产者、单一消费者能否在无锁的环境中工作?
原标题:Is multiple-producer, single-consumer possible in a lockfree setting?

I have a bunch of threads that are doing lots of communication with each other. I would prefer this be lock free.

对于每一个路面,我想有一个邮箱,其他路面可以发送电文(但只有所有人可以删除电文)。 这是多产单消费情况。 我能否在无锁定/高业绩的情况下这样做? (这处在巨型模拟的神经中途。)

最佳回答

如果你有原子<代码>,则确保: 比较:AndSwap 指示:

for (i = 0; ; i = (i + 1) % MAILBOX_SIZE)
{
    if ((mailbox[i].owned == false) &&
        (CompareAndSwap(&mailbox[i].owned, true, false) == false))
        break;
}

mailbox[i].message = message;
mailbox[i].ready = true;

阅读了电文后,便装订了<条码>邮箱[i].ready = 虚假;邮箱[i]自有;(按该顺序)。

问题回答

多种生产者单一消费者 学费是最容易采用的无锁算法之一。

最基本的执行需要一个简单、无锁的、只带有推力的(SList)清单。 这些功能可在视窗软件中作为InterdleFlushSList()和IntertarPushEntrySList(SList)提供,但这些功能很容易在你自己推出。

多家生产商使用化学文摘社(闭门比较和交换)将物品运往SList。

单一消费者使用XCHG(闭门交易所)向SList的头部转移。 然后,消费者有一份相反顺序的项目清单。

为了处理这些物品,在处理之前,你必须简单地扭转从流体中退回的清单。 如果你不关心秩序,你就能够立即抽出名单处理。

2. 您履行自己的职责时,请作两笔说明:

(1) 如果您的记忆秩序软弱(即电传机),你需要在推进功能开始时设置“传承屏障”,并在变式功能结束时设置“需要记忆障碍”。

2) 你可以大大简化和优化这些职能,因为与SList的ABA-issue在流行期间发生。 如果你只使用推力(推力)和流体(流体)的话,你就不会有ABA-问题。 这意味着,作为与非24条码非常相似的单一联络点,你可以执行,不需要ABA预防序列。

http://www.research.ibm.com/people/m/michael/podc-1996.pdf rel=“nofollow noreferer” ,Rochester大学的论文,其中说明不存在24小时的并行问题:。 文件中描述的算法显示了一种无锁定点的技术。

我记得,英特尔开发商讲的是,他提到了一条大致如此的内容。





相关问题
Personalized Welcome Messages

How do I create a welcome message on my home page with user s name in it? Dragging dynamic fields from the recordset onto my page does not work: <cfoutput>#Recordset1.Username#</cfoutput>...

how do i get mysql warning messages in php (not error)

i want to execute a sql at php which does something like changing a text column into int column. however, this sql failed to fun at php and succeeds in my mysql admin tool (sqlyog). server responses "...

jQuery queue messages

I ve got a short function that should show messages on a website. function showHint() { $( #notify ).html( message text ).show( slide , {direction: right }, 500); } And there is another ...

C++ message passing doubts

I m writing a piece of sotware that needs objects that exchange messages between each other. The messages have to have the following contents: Peer *srcPeer; const char* msgText; void* payload; int ...

How to find out if a thread has message queue?

Is there any way to find out from threadId , if a thread has message queue or not? Basically there are some windows api which only work if a thread has message queue.window

keyboard hook in windows C++ or what?

I wish to build my own application which can send keyboard commands(messages) to the Windows OS. For example when I press the combination ctrl+shift+n, I wish to launch the notepad.exe . How can I ...

Handling multiple windows WIN32 API

HI I m trying to create an application in the Win32 environment containing more than one window. How do i do that? all the Win32 Tutorials on web i found only showed how to manage one window. How do i ...

热门标签