Part 1
요약·해설
Zephyr가 일반 POSIX OS와 다른 점, build-time syscall과 libposix·공통 library 설계 원칙을 설명합니다.
Single linked image
Thin POSIX library
No dependency cycles
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
8EEC79FAE4864B6C5B64EA93EC72F55519820CA3BAD236BB8504A5957E1374E6
.. _posix_details:
Implementation Details
######################
In many ways, Zephyr provides support like any POSIX OS; API bindings are provided in the C
programming language, POSIX headers are available in the standard include path, when configured.
Unlike other multi-purpose POSIX operating systems
- Zephyr is not "a POSIX OS". The Zephyr kernel was not designed around the POSIX standard, and
POSIX support is an opt-in feature
- Zephyr apps are not linked separately, nor do they execute as subprocesses
- Zephyr, libraries, and application code are compiled and linked together, running similarly to
a single-process application, in a single (possibly virtual) address space
- Zephyr does not provide a POSIX shell, compiler, utilities, and is not self-hosting.
.. note::
Unlike the Linux kernel or FreeBSD, Zephyr does not maintain a static table of system call
numbers for each supported architecture, but instead generates system calls dynamically at
build time. See :ref:`System Calls <syscalls>` for more information.
Design
======
As a library, Zephyr's POSIX API implementation makes an effort to be a thin abstraction layer
between the application, middleware, and the Zephyr kernel.
Some general design considerations:
- The POSIX interface and implementations should be part of Zephyr's POSIX library, and not
elsewhere, unless required both by the POSIX API implementation and some other feature. An
example where the implementation should remain part of the POSIX implementation is
``getopt()``. Examples where the implementation should be part of separate libraries are
multithreading and networking.
- When the POSIX API and another Zephyr subsystem both rely on a feature, the implementation of
that feature should be as a separate Zephyr library that can be used by both the POSIX API and
the other library or subsystem. This reduces the likelihood of dependency cycles in code. When
practical, that rule should expand to include macros. In the example below, ``libposix``
depends on ``libzfoo`` for the implementation of some functionality "foo" in Zephyr. If
``libzfoo`` also depends on ``libposix``, then there is a dependency cycle. The cycle can be
removed via mutual dependency, ``libcommon``.
.. graphviz::
:caption: Dependency cycle between POSIX and another Zephyr library
digraph {
node [shape=rect, style=rounded];
rankdir=LR;
libposix [fillcolor="#d5e8d4"];
libzfoo [fillcolor="#dae8fc"];
libposix -> libzfoo;
libzfoo -> libposix;
}
.. graphviz::
:caption: Mutual dependencies between POSIX and other Zephyr libraries
digraph {
node [shape=rect, style=rounded];
rankdir=LR;
libposix [fillcolor="#d5e8d4"];
libzfoo [fillcolor="#dae8fc"];
libcommon [fillcolor="#f8cecc"];
libposix -> libzfoo;
libposix -> libcommon;
libzfoo -> libcommon;
}
- POSIX API calls should be provided as regular callable C functions; if a Zephyr
:ref:`System Call <syscalls>` is needed as part of the implementation, the declaration and the
implementation of that system call should be hidden behind the POSIX API.
Part 3
한국어 전문 번역
Zephyr는 일반 POSIX OS처럼 C programming language의 API binding과, 설정 시 standard include path에서 사용할 POSIX header를 제공합니다.
그러나 multi-purpose POSIX operating system과는 다음 점이 다릅니다.
- Zephyr kernel은 POSIX 표준을 중심으로 설계된 'POSIX OS'가 아니며 POSIX support는 opt-in 기능입니다.
- Zephyr application은 별도로 link되거나 subprocess로 실행되지 않습니다.
- Zephyr, library와 application code가 함께 compile·link되어 하나의, 경우에 따라 virtual인 address space에서 single-process application처럼 실행됩니다.
- POSIX shell, compiler와 utility를 제공하지 않으며 self-hosting OS가 아닙니다.
Design
Library로서 Zephyr POSIX API implementation은 application·middleware와 Zephyr kernel 사이의 얇은 abstraction layer가 되도록 설계합니다.
- POSIX interface와 implementation은 다른 기능에도 꼭 필요한 경우가 아니라면 Zephyr POSIX library 안에 둡니다.
getopt()는 POSIX implementation에 남고, multithreading과 networking처럼 공용성이 큰 기능은 별도 library에 둡니다. - POSIX API와 다른 subsystem이 같은 기능에 의존하면 양쪽이 함께 사용할 별도 Zephyr library로 구현해 dependency cycle 가능성을 줄입니다. 가능하면 macro에도 같은 원칙을 적용합니다.
libposixfoo 구현을 위해 libzfoo에 의존libzfooPOSIX 기능 때문에 libposix에 의존libposixlibzfoo와 libcommon 사용libzfoolibcommon 사용libcommon공유 기능을 독립 제공POSIX API call은 일반 callable C function으로 제공해야 합니다. 내부 구현에 Zephyr System Call이 필요하다면 그 declaration과 implementation은 POSIX API 뒤에 숨겨 application에 노출하지 않습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.