-
-
Notifications
You must be signed in to change notification settings - Fork 721
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
Comments
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. |
自己实现个队列 也没几行代码 |
Implement a queue by yourself without a few lines of code |
用tbox实现一个生产者消费者模型,其中包含了生产者信号量、消费者信号量、队列、锁,调试中发现锁操作太耗时,想着去掉锁。但发现队列是用单链表实现的,而单链表里有对变量size进行自增自减操作,这个在多核下会出问题。
有什么解决办法吗?想着将size的类型改成tb_atomic_t,然后把size相关的操作都改下,可以吗?
The text was updated successfully, but these errors were encountered: