Giter VIP home page Giter VIP logo

Comments (4)

psavol avatar psavol commented on June 9, 2024

/** 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.

Neetika02 avatar Neetika02 commented on June 9, 2024

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.

JannePeltonen avatar JannePeltonen commented on June 9, 2024

Yes. See atomic.h or https://opendataplane.github.io/odp/group__odp__atomic.html#ga9568820afe533a23dbdd8982ca6420cf

from odp.

Neetika02 avatar Neetika02 commented on June 9, 2024

Thanks a lot for the help :)

from odp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.