Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单链表中的size可否添加原子操作限定符 #222

Open
misskimi opened this issue Aug 15, 2023 · 3 comments
Open

单链表中的size可否添加原子操作限定符 #222

misskimi opened this issue Aug 15, 2023 · 3 comments

Comments

@misskimi
Copy link

用tbox实现一个生产者消费者模型,其中包含了生产者信号量、消费者信号量、队列、锁,调试中发现锁操作太耗时,想着去掉锁。但发现队列是用单链表实现的,而单链表里有对变量size进行自增自减操作,这个在多核下会出问题。
有什么解决办法吗?想着将size的类型改成tb_atomic_t,然后把size相关的操作都改下,可以吗?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Can the size in the singly linked list add atomic operation qualifiers

Use tbox to implement a producer-consumer model, which includes producer semaphores, consumer semaphores, queues, and locks. During debugging, it is found that the lock operation is too time-consuming, so I want to remove the lock. However, it is found that the queue is implemented with a single-linked list, and the single-linked list has self-increment and self-decrement operations on the variable size, which will cause problems under multi-core.
Is there any solution? I want to change the type of size to tb_atomic_t, and then change all size-related operations, is it possible?

@waruqi
Copy link
Member

waruqi commented Aug 15, 2023

自己实现个队列 也没几行代码

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Implement a queue by yourself without a few lines of code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants