kernel/data_structures/index.html · kernel/data_structures/index.rst 공식 원문 ↗

Zephyr 3.7.0 · Kernel · Data Structures

커널 자료구조

동적 할당 없이 사용할 수 있는 intrusive 목록·트리·ring buffer의 공통 설계 원칙을 설명합니다.

Official pathkernel/data_structures/index.html
Source filekernel/data_structures/index.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Zephyr 자료구조는 node를 사용자 구조체에 내장하며, 기본 동기화를 제공하지 않아 호출자가 잠금을 책임집니다.

Ownership

Intrusive nodes

Allocation

User-provided memory

Locking

Caller-managed

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 7D7D313245D3A321CBAFC135734F0DC9223E88BDBA0300859522437EF2EE089A
.. _data_structures:

Data Structures
###############

Zephyr provides a library of common general purpose data structures
used within the kernel, but useful by application code in general.
These include list and balanced tree structures for storing ordered
data, and a ring buffer for managing "byte stream" data in a clean
way.

Note that in general, the collections are implemented as "intrusive"
data structures.  The "node" data is the only struct used by the
library code, and it does not store a pointer or other metadata to
indicate what user data is "owned" by that node.  Instead, the
expectation is that the node will be itself embedded within a
user-defined struct.  Macros are provided to retrieve a user struct
address from the embedded node pointer in a clean way.  The purpose
behind this design is to allow the collections to be used in contexts
where dynamic allocation is disallowed (i.e. there is no need to
allocate node objects because the memory is provided by the user).

Note also that these libraries are uniformly unsynchronized; access to
them is not threadsafe by default.  These are data structures, not
synchronization primitives.  The expectation is that any locking
needed will be provided by the user.

.. toctree::
  :maxdepth: 1

  slist.rst
  dlist.rst
  mpsc_pbuf.rst
  spsc_pbuf.rst
  rbtree.rst
  ring_buffers.rst
  mpsc_lockfree.rst
  spsc_lockfree.rst

Part 3

한국어 전문 번역

Zephyr는 커널 내부에서 쓰이면서 일반 애플리케이션 코드에도 유용한 범용 자료구조 라이브러리를 제공합니다. 정렬된 데이터를 저장하는 목록과 균형 트리, 바이트 스트림 데이터를 깔끔하게 관리하는 ring buffer가 여기에 포함됩니다.

일반적으로 이 collection들은 intrusive 자료구조로 구현됩니다. 라이브러리 코드가 사용하는 구조체는 node뿐이며, 그 node가 어떤 사용자 데이터를 소유하는지 나타내는 pointer나 metadata를 저장하지 않습니다. 대신 node 자체를 사용자가 정의한 구조체 안에 포함합니다. 내장된 node pointer로부터 사용자 구조체 주소를 안전하게 얻는 macro가 제공됩니다.

이 설계는 동적 할당을 허용하지 않는 환경에서도 collection을 쓸 수 있게 합니다. Node 객체를 따로 할당할 필요 없이 사용자가 메모리를 제공하기 때문입니다.

이 라이브러리들은 모두 동기화를 수행하지 않으므로 기본적으로 thread-safe하지 않습니다. 자료구조이지 동기화 primitive가 아니며, 필요한 잠금은 사용자가 제공해야 합니다.

하위 문서는 single-linked list, double-linked list, MPSC/SPSC packet buffer, red/black tree, ring buffer, MPSC/SPSC lock-free queue를 다룹니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.