Comments (4)
/** Not multithread safe operation
*
- Queue operation (enqueue or dequeue) may not be multithread safe.
- Application ensures synchronization between threads so that
- simultaneously only single thread attempts the operation on
- the same queue. */
ODP_QUEUE_OP_MT_UNSAFE
When application specifies that queue enq_mode/deq_mode may be MT_UNSAFE, it must not call the enq/deq operation simultaneously from multiple threads. MT_UNSAFE tells to the implementation that less locks/atomics is needed to protect the queue. This mode selection is per operation, so you can request e.g. a multi-producer / single-consumer queue with enq_mode=MT_SAFE + deq_mode=MT_UNSAFE. With that setting, multiple threads may call queue enqueue simultaneously, but only one thread (at a time) can call queue dequeue (for that queue).
Nonblocking setting is interesting when you need to ensure thread a thread blocked inside a queue operation cannot block other threads using the same queue. The default (ODP_BLOCKING) setting is more performant than nonblocking ones, when queues are implemented in SW. Where as, a HW based implementation may not care about this setting as it's always nonblocking.
These queues may be implemented with SW rings/lists or HW queues. ODP_DPDK does not utilize DPDK rings for these, but uses our own SW ring implementation (which is optimized for this API).
These queues are designed to pass events between HW and SW, or between SW threads. These event queues may be connected to the event scheduler as well. ODP has also stash API, which is targeted as a simple storage (LIFO or FIFO) of application specific object handles. Depending on the ODP implementation, stash may be implemented as a SW ring or HW pool.
from odp.
Thanks a lot for the detailed reply. It helps a lot.
I will be using these queues between SW threads as you suggested with enq_mode as MT_SAFE and deq_mode as MT_UNSAFE.
Could you please also help me with another thing. Is there any primitive that ODP provides for implementing a CAS instruction. e.g. If I want to keep a flag which will be read and set by different threads, I want to use a Test&Set type of instruction for accessing this flag as it will provide synchronized access in single cycle. So Is there any CAS primitive I can use to set a simple flag with value 0 or 1?
from odp.
Yes. See atomic.h or https://opendataplane.github.io/odp/group__odp__atomic.html#ga9568820afe533a23dbdd8982ca6420cf
from odp.
Thanks a lot for the help :)
from odp.
Related Issues (20)
- Multicast receive not enabled on linux-generic/dpdk pktio
- odp_term_global() crashes in multiprocess scenarios HOT 2
- SIGSEGV from odp_event_type HOT 1
- fragment pkt has invalid segment count HOT 1
- fallocate is interrupted by signal at startup HOT 8
- Does ODP has any plan to support XDP ? HOT 4
- Missing closing files HOT 1
- Compiled failed with enable dpdk in v1.33.0.0 HOT 3
- crash in odp_packet_trunc_tail() while split packet HOT 24
- Run ODP on a bare metal as Rx and send pakets from a Linux with netcat (UDP is ok) HOT 3
- Segmentation fault with ODP 1.34 HOT 2
- Backward compatibility
- pci_whitelist/pci_blacklist configuration options for dpdk pktio HOT 3
- XDP pktio sends malformed packets HOT 3
- XDP support documentation HOT 5
- XDP Cannot receive packets with 'direct mode' API HOT 5
- Missing ethernet padding remove while reassemble small fragment
- Invalid packets received when using vfio-pci driver HOT 3
- why odp_timer_current_tick returns ns rather than the curr_tick? HOT 2
- ERR: odp_init.c:617:odp_init_local(): odp_init_local() called multiple times by the same thread HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odp.