> For the complete documentation index, see [llms.txt](https://sdn.feisky.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sdn.feisky.xyz/wang-luo-ji-chu/index-3/ivshmem.md).

# Ring和共享内存

## DPDK Ring

DPDK Ring提供了一个FIFO无锁队列，支持丰富的队列操作，比如

* Multi-consumer or single-consumer dequeue
* Multi-producer or single-producer enqueue
* Bulk dequeue - Dequeues the specified count of objects if successful; otherwise fails
* Bulk enqueue - Enqueues the specified count of objects if successful; otherwise fails
* Burst dequeue - Dequeue the maximum available objects if the specified count cannot be fulfilled
* Burst enqueue - Enqueue the maximum available objects if the specified count cannot be fulfilled

![](/files/-LDZS6SQig-E8sIvjyGc)

## ivshmem

ivshmem则通过把内存映射成虚拟机PCI设备提供了虚拟机间(host-to-guest or guest-to-guest)共享内存的机制。

![](/files/-LDZS6SS9pRhhIOekTgE)

DPDK ivshmem:

![](/files/-LDZS6SUiAf1ZQ58ckh7)

### ivshmem使用示例

```bash
# on the host
mount tmpfs /dev/shm -t tmpfs -osize=32m
ivshmem_server -m 64 -p/tmp/nahanni &

# start VM
qemu-system-x86_64  -hda mg -L /pc-bios/ --smp 4 –chardev socket,path=/tmp/nahanni,id=nahanni-device ivshmem,chardev=nahanni,size=32m,msi=off -serial telnet:0.0.0.0:4000,server,nowait,nodelay-enable-kvm&

# inside VM
modprobe kvm_ivshmem
cat/proc/devices | grep kvm_ivshmem
mknod-mode=666 /dev/ivshmem c 245 0
```

**参考文档**

* [DPDK Ring Library](http://dpdk.org/doc/guides/prog_guide/ring_lib.html)
* [DPDK IVSHMEM Library](http://dpdk.org/doc/guides-16.04/prog_guide/ivshmem_lib.html)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sdn.feisky.xyz/wang-luo-ji-chu/index-3/ivshmem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
