This repository was archived by the owner on Nov 26, 2025. It is now read-only.
Discussion of the improvement of libctest #31
LIN-Matrix
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
1. Implementing TLS for Cross-Architecture Compatibility
To enable compatibility with both
x86_64andaarch64, Thread-Local Storage (TLS) support is introduced and integrated into task context management. TLS is crucial for handling per-thread data and is frequently accessed by the C library during runtime.Core Mechanism
The TLS area is managed through the
fs_basefield within theTaskContextstructure. Two accessor methods are implemented:These functions respectively read from and write to the
fs_base, which stores the base address of the current task’s TLS region. This mechanism is crucial for proper management of thread-local data.Integration with Context Switching
During a context switch, TLS pointers must be saved and restored to maintain task-specific state:
This ensures that each task regains its thread-local data when it resumes execution. Moreover,
clone_task()is modified to explicitly set the TLS base for new tasks by invoking:Without this step, cloned tasks would lose access to TLS, leading to unpredictable behavior, especially in libc-based environments.
2. Enhancing System Call Compatibility
Several system calls essential to libc startup routines were either implemented or stubbed to ensure smooth execution of dynamically linked applications.
Key Additions
statfs: Returns dummy EXT4 values, allowing filesystem checks to pass.getppid,gettid,set_tid_address: Return reasonable defaults used by libc.prlimit64,rt_sigtimedwait: Stub implementations returning success to bypass failures during initialization.These system calls are commonly invoked when programs initialize standard I/O, memory allocation, and environment parsing routines.
Dispatcher Updates
To ensure proper routing, all the newly supported system calls are registered in the syscall dispatcher. This eliminates the fallback to the
ENOSYSpath and avoids terminating tasks prematurely.3. Adapting the Main Function for Structured Output
The structure of the
main()function is modified to accommodate test output parsing during automated evaluation. The original approach merged all tests in a single loop, injecting markers based on case index to delineate test groups:This approach works without requiring additional environment variables, but it relies on knowing the precise number of test cases in each group, which can be fragile if the test set changes.
4. Alternative Grouping Strategy
Before adopting the above design, a different method was explored based on BattiestStone4’s approach. That strategy created separate environment variables and test case lists for each group (
basic,libctest-musl,libctest-glibc), allowing the test runner to handle them in two distinct loops:This method is more robust when the number of test cases varies but introduces additional Makefile complexity and slight duplication in code structure.
5. Summary of Improvements
The following table outlines the major modifications and their impact:
tls()andset_tls()accessors and integrated into context switchclone_taskUpdateTogether, these changes significantly improve the system’s support for POSIX-compliant applications and ensure compatibility with
libctest, making ArceOS a more robust and versatile kernel for multi-architecture deployment.Beta Was this translation helpful? Give feedback.
All reactions