Open cfriedt opened 2 years ago
Architecture WG:
- @cfriedt: when ever implementing dynamic features in the scheduler / core code (not yet defined safety scope) please consider safety where dynamic memory management and using heaps is problematic to get TÜV certification.
Absolutely
But I remember that we had that discussion earlier already and solved that by layering the dynamic part on top of the core code which can be passed statically OR dynamically allocated objects such as stack buffers, thread contexts etc. what so ever. I feel you are aware of that.
Yeah, so the suggested approach from an earlier PR was to keep thread stack allocation separate and selectable, so that will still be the case. However, the proposed kernel-level API will also allow
Yeah, so the suggested approach from an earlier PR was to keep thread stack allocation separate and selectable, so that will still be the case. However, the proposed kernel-level API will also allow
- a static, pre-allocated pool of thread stacks to be used
- dynamic, heap-allocated thread stacks to be used
- both of the above (with a configurable preference)
- and of course neither
Like it!
Would be kind of nice to be able to use socketpair()
without networking. I wonder if something can be borrowed from eventfd
.. 🤔
@cfriedt you updated names. but references are still to non-PSE pages ;)
@cfriedt you updated names. but references are still to non-PSE pages ;)
Actually, all three are referenced from "Conformance Test Suites" already. I was just trying to provide a reference to the higher scope specifications as well.
In any case, the information is available.
TSC Attention Required
Please refer to
POSIX System Interfaces POSIX Application Environment Profiles
Why should the PRs below be considered for approval after Feature Freeze?
POSIX_DEVICE_IO
, POSIX_FD_MGMT
POSIX_FD_MGMT
, POSIX_DEVICE_IO
would likely be required for libc bugfixes (properly utilizing zvfs layer).What are the PR's we are asking to merge?
Allow toolchains / platforms to override POSIX Option Groups via Kconfig (mainly for maintainers, libc compatibility)
Add stubs for the POSIX_SIGNALS
Option Group (i.e. signalling processes. We do not yet have processes in Zephyr, so stubs for functions that are simply not supportable)
Implement POSIX_DEVICE_IO
Option Group (depended on mmap, so a bit delayed. lays groundwork for zvfs, extremely useful in terms of reducing api-layer dependency cycles)
Implement POSIX_FD_MGMT
Option Group (zvfs_poll()
, zvfs_select()
, extremely useful in terms of reducing api-layer dependency cycles)
What are we leaving behind?
System Inferfaces (Base Definitions)
For most practical purposes, the System interfaces are feature complete 🎉(with caveats).
[ ] https://github.com/zephyrproject-rtos/zephyr/pull/74918
_POSIX_REALTIME_SIGNALS
although tests are passing, this was rejected by the TSC since it did not make the feature freeze cutoff, because it had not been fully reviewed, and because more documentation was requested_POSIX_THREADS
puzzle (pthread_kill()
)[ ] https://github.com/zephyrproject-rtos/zephyr/pull/74394
_POSIX_THREAD_SAFE_FUNCTIONS
very close to being done, but still needs review time, has dependencies on posix device io, etcPSE51 - Minimal Realtime System Profile
For most practical purposes, PSE51 is feature complete 🎉(with caveats).
fdatasync()
, so a conformant app can still link)_POSIX_THREAD_SPORADIC_SERVER
(missing SCHED_SPORADIC
constant)PSE52 - Realtime Controller System Profile
POSIX_FILE_SYSTEM
subsys/fs
requires better fdtable
integration (i.e. using per-file-descriptor offset, rather than per-file offset)_POSIX_TRACE*
PSE53 - Dedicated Realtime System Profile
Why did some features not make it in for Feature Freeze?
Post-freeze Bug-fixes and Stability-fixes (possible backports)
#if defined(_POSIX_PRIORITY_SCHEDULING)
)sys/features.h
instead of posix_features.h
signal.h
and time.h
into minimal libc to reduce conflicts between Newlib / Picolibc / Minimal libc_POSIX_THREADS
(lib/posix/options/CMakeLists.txt
)Updated comment to reflect that the the posix device_io, signals, and fd_mgmt features were reverted.
This puts LTSv3 in a kind of dilapidated state from the POSIX & libc perspective.
Introduction
POSIX libraries and applications should Just Work™️ in 90% of the cases when being ported to Zephyr. Why? Because we want to enable our users to launch products and applications to the best of our ability, and we want to lower the barrier to entry by enabling users to leverage portable APIs.
This is an umbrella issue that will outlines work to be done in the POSIX API prior to LTSv3 (Ideally complete by v3.5).
Problem description
As discussed at EOSS 2023 and EOSS 2024, Zephyr's POSIX API layer needs some improvements. These can be broken down into the following:
Proposed change
Implement all Option Requirements of POSIX Subprofiling Option Groups required for PSE51, PSE52, and most of PSE53 compatibility.
Update the POSIX areas at docs.zephyrproject.org. For reference, the top level page of Zephyr's POSIX documentation.
https://docs.zephyrproject.org/latest/services/portability/posix/index.html
Maintainability addresses the needs of the maintainer, contributors, and (to some extent) the users.
Interface addresses the needs of
_POSIX_C_SOURCE
,_XOPEN_SOURCE
)_POSIX_TIMERS
)Portability addresses the needs of the users who should (rightfully) expect that the POSIX API layer behaves according to the specification.
Detailed RFC
Proposed change (Detailed)
Maintainability
subsys/net
,subsys/fs
, andlib/posix
#include_next
is required for the aboveCONFIG_ARCH_POSIX
andCONFIG_POSIX_API
are mutually exclusiveCONFIG_NET_SOCKETS_POSIX_NAMES
CONFIG_POSIX_API
in spite of the fact that the BSD Sockets API is part of POSIXThe layering issues that exist between
subsys/net
andlib/posix
can be described as a cyclic dependency. The issue can be resolved via mutual dependency.I.e. Currently, we have:
But we need
Diagrams made with https://asciiflow.com/
I think we may have settled on the name "ZVFS" in the above diagram.
Interface
[x] Include a clear reference to the POSIX standard in Zephyr's documentation
Plan for formally supporting Real-Time and Embedded Profiles of IEEE Std 1003.13-2003 (a.k.a. PSE52)
With
CONFIG_POSIX_API
, Ensure POSIX headers can be included as#include <poll.h>
rather than#include <zephyr/posix/poll.h>
POSIX_SINGLE_PROCESS
POSIX_SIGNALS
POSIX_DEVICE_IO
POSIX_FD_MGMT
POSIX_SEMAPHORES
_POSIX_MESSAGE_PASSING
_POSIX_PRIORITY_SCHEDULING
_POSIX_READER_WRITER_LOCKS
_POSIX_THREAD_PRIORITY_SCHEDULING
_POSIX_TIMEOUTS
_XOPEN_STREAMS
_POSIX_SPIN_LOCKS
(mandatory for the base specification)pthread_spin_destroy()
pthread_spin_init()
pthread_spin_lock()
pthread_spin_trylock()
pthread_spin_unlock()
_POSIX_THREADS
_POSIX_CLOCK_SELECTION
_POSIX_SHARED_MEMORY_OBJECTS
_POSIX_CPUTIME
_POSIX_TIMERS
_POSIX_REALTIME_SIGNALS
_POSIX_SYNCHRONIZED_IO
fsync()
msync()
_POSIX_THREAD_PRIO_PROTECT
_POSIX_THREAD_SAFE_FUNCTIONS
Address regular bugs and enhancement requests
Dependencies
Concerns and Unresolved Questions
Alternatives
There was a previous massive PR that attempted to address a number of the goals at once (#43987), but it is impossible to review in the current state and needs to be broken down and simplified in separate individual PRs.