ABSTRACT

Software designers need to use the effective data-sharing methods among CPU cores such as data synchronization and critical resource protection. This chapter describes the rte_ring, rte_atomic, lock-free, memory barrier concept. From the computing perspective, atomic operation refers to "one operation cannot be interrupted". Compare and swap is a common way for multi-threading to achieve synchronization. Linux kernel supports the atomic operations for simple flags, atomic counters, exclusive ownership, and shared ownership in the multi-threaded environment. The lock software interface is based on the atomic operations using compare and exchange; the caller block mechanism is implemented with "PAUSE" instruction within the endless loop mechanism. Lock helps the data synchronization, but it forces the other cores to wait until the shared resource is available. Atomic, memory barriers are the fundamental concept for multi-threaded software; atomic interface is available on bits and integer level.