@@ -3,85 +3,370 @@ menuconfig RT_USING_LWP
33 depends on RT_USING_SMART
44 default y
55 help
6- The lwP is a light weight process running in user mode.
6+ LWP (Light Weight Process) provides user-space process support in RT-Smart mode.
7+
8+ Features:
9+ - User-space and kernel-space separation
10+ - Process isolation with MMU/MPU
11+ - POSIX process APIs (fork, exec, waitpid, etc.)
12+ - Inter-process communication (IPC)
13+ - Signal handling
14+ - Dynamic linking and loading (LDSO)
15+
16+ Benefits:
17+ - Memory protection between processes
18+ - Fault isolation (process crash doesn't affect kernel)
19+ - Multi-user application support
20+ - Better security and stability
21+
22+ Requirements:
23+ - RT_USING_SMART must be enabled
24+ - CPU with MMU or MPU support
25+ - DFS v2.0 for file system access
26+
27+ Use cases:
28+ - Running untrusted user applications
29+ - Mixed-criticality systems
30+ - Applications requiring process isolation
31+ - POSIX application porting
32+
33+ Note: LWP is the foundation of RT-Smart user-space support.
34+ Required for running user-space applications.
735
836if RT_USING_LWP
937 menuconfig LWP_DEBUG
1038 bool "Enable debugging features of LwP"
1139 default n
40+ help
41+ Enable debugging and tracing features for LWP processes.
42+
43+ Debug features:
44+ - Process state transitions logging
45+ - Memory allocation tracking
46+ - IPC operation tracing
47+ - Signal delivery monitoring
48+
49+ Useful for:
50+ - Development and debugging
51+ - Troubleshooting process issues
52+ - Performance analysis
53+ - System behavior understanding
54+
55+ Overhead:
56+ - Increased log output
57+ - Slightly slower process operations
58+ - Additional ROM for debug strings (~2-4KB)
59+
60+ Enable during development, disable in production for performance.
1261
1362 if LWP_DEBUG
1463 config LWP_DEBUG_INIT
1564 select RT_USING_HOOKLIST
1665 bool "Enable debug mode of init process"
1766 depends on LWP_USING_RUNTIME
1867 default y
68+ help
69+ Enable detailed debugging for init process (PID 1).
70+
71+ Traces init process activities:
72+ - Boot script execution
73+ - Child process spawning
74+ - Signal handling
75+ - Shutdown sequence
76+
77+ Useful for debugging system startup and shutdown issues.
78+ Requires LWP_USING_RUNTIME enabled.
1979 endif
2080
2181 config LWP_USING_RUNTIME
2282 bool "Using processes runtime environment (INIT process)"
2383 default y
2484 help
25- Runtime environment provide by init process including boot scripts,
26- poweroff, shutdown, reboot, etc.
85+ Enable init process and runtime environment for user-space.
86+
87+ Provides Linux-like init system (PID 1) that:
88+ - Starts as first user process
89+ - Executes boot scripts (/etc/rc.local, /etc/init.d/*)
90+ - Manages system lifecycle
91+ - Handles orphaned processes
92+ - Provides system commands (poweroff, reboot, shutdown)
93+
94+ Features:
95+ - Boot script support for auto-starting applications
96+ - Graceful shutdown handling
97+ - Process reaping (zombie cleanup)
98+ - System service management
99+
100+ Required for:
101+ - Complete RT-Smart user-space environment
102+ - Automatic application startup
103+ - System lifecycle management
104+
105+ Disable only for minimal systems without init process.
27106
28107 config RT_LWP_MAX_NR
29108 int "The max number of light-weight process"
30109 default 30
110+ help
111+ Maximum number of processes that can run simultaneously.
112+
113+ Default: 30 processes
114+
115+ Each process uses:
116+ - ~200-400 bytes for process control block
117+ - Separate page tables (MMU systems)
118+ - Individual memory spaces
119+
120+ Total memory: RT_LWP_MAX_NR × ~300 bytes (minimum)
121+
122+ Increase for:
123+ - Systems running many concurrent applications
124+ - Multi-user environments
125+
126+ Decrease to save memory on constrained systems.
127+ Minimum recommended: 8-10 processes.
31128
32129 config LWP_TASK_STACK_SIZE
33130 int "The lwp thread kernel stack size"
34131 default 16384
132+ help
133+ Kernel stack size for each LWP thread in bytes.
134+
135+ Default: 16384 bytes (16KB)
136+
137+ This is the kernel-mode stack used when process enters kernel via:
138+ - System calls
139+ - Exception handling
140+ - Interrupt processing
141+
142+ Stack usage depends on:
143+ - System call complexity
144+ - Nested interrupt depth
145+ - Kernel function call chains
146+
147+ Increase if:
148+ - Kernel stack overflow errors
149+ - Deep system call nesting
150+ - Complex device drivers
151+
152+ Decrease to save RAM (minimum ~8KB for basic operations).
153+ Each LWP thread requires this much kernel stack.
35154
36155 config RT_CH_MSG_MAX_NR
37156 int "The maximum number of channel messages"
38157 default 1024
158+ help
159+ Maximum number of messages in channel IPC message pool.
160+
161+ Default: 1024 messages
162+
163+ Channels provide RT-Thread's native IPC mechanism for LWP:
164+ - Higher performance than POSIX IPC
165+ - Direct memory-mapped communication
166+ - Zero-copy message passing
167+
168+ Each message slot uses ~32-64 bytes depending on message size.
169+
170+ Increase for:
171+ - High-frequency IPC between processes
172+ - Many concurrent channel communications
173+
174+ Decrease to save memory if channel IPC not heavily used.
39175
40176 config LWP_TID_MAX_NR
41177 int "The maximum number of lwp thread id"
42178 default 64
179+ help
180+ Maximum number of thread IDs available for LWP threads.
181+
182+ Default: 64 thread IDs
183+
184+ Each process can create multiple threads. This limits total
185+ thread IDs across all processes.
186+
187+ Typical usage:
188+ - Single-threaded processes: 1 TID each
189+ - Multi-threaded processes: N TIDs per process
190+
191+ Total threads = sum of threads in all processes
192+
193+ Increase for:
194+ - Applications creating many threads
195+ - Many multi-threaded processes
196+
197+ Decrease if applications mostly single-threaded.
43198
44199 config LWP_ENABLE_ASID
45200 bool "The switch of ASID feature"
46201 depends on ARCH_ARM_CORTEX_A
47202 default y
203+ help
204+ Enable Address Space ID (ASID) for Cortex-A processors.
205+
206+ ASID provides hardware-based process identification:
207+ - Tags TLB entries with process ID
208+ - Avoids TLB flush on context switch
209+ - Significantly faster process switching
210+
211+ Performance impact:
212+ - 50-70% faster context switch between processes
213+ - Better TLB hit rate
214+ - Reduced MMU overhead
215+
216+ Automatically enabled for Cortex-A (recommended).
217+ Only disable for debugging TLB-related issues.
218+
219+ Note: Requires CPU with ASID support (ARMv7-A and above).
48220
49221 if ARCH_MM_MMU
50222 config RT_LWP_SHM_MAX_NR
51223 int "The maximum number of shared memory"
52224 default 64
225+ help
226+ Maximum number of shared memory segments for inter-process communication.
227+
228+ Default: 64 segments
229+
230+ Shared memory provides:
231+ - Fastest IPC method (direct memory access)
232+ - POSIX shm_open()/shm_unlink() APIs
233+ - mmap() for memory-mapped sharing
234+
235+ Each segment descriptor uses ~40-60 bytes.
236+
237+ Increase for:
238+ - Applications using extensive shared memory
239+ - Multiple processes sharing data
240+ - High-performance IPC requirements
241+
242+ Decrease to save memory if shared memory rarely used.
53243
54244 config LWP_USING_MPROTECT
55245 bool
56246 default n
57247 help
58- ARCH has the support of mprotect
248+ Architecture has mprotect() support for memory protection.
249+
250+ mprotect() allows changing memory region permissions:
251+ - Read, write, execute permissions
252+ - Guard pages for stack overflow detection
253+ - Memory region isolation
254+
255+ Automatically enabled by architecture support.
256+ User does not configure directly.
59257 endif
60258
61259 if ARCH_MM_MPU
62260 config RT_LWP_MPU_MAX_NR
63261 int "The maximum number of mpu region"
64262 default 2
263+ help
264+ Maximum number of MPU regions per process.
265+
266+ Default: 2 regions per process
267+
268+ MPU provides memory protection without full MMU:
269+ - Limited number of protection regions
270+ - Simpler than MMU but less flexible
271+
272+ Regions typically used for:
273+ - Code region (read-execute)
274+ - Data region (read-write)
275+ - Stack guard region
276+
277+ Limited by hardware MPU region count.
278+ Check your CPU MPU capabilities.
65279
66280 config RT_LWP_USING_SHM
67281 bool "Enable shared memory"
68282 default y
283+ help
284+ Enable shared memory support for MPU-based systems.
285+
286+ Provides shared memory IPC even without MMU:
287+ - Processes can share memory regions
288+ - Requires careful MPU configuration
289+ - More limited than MMU-based sharing
290+
291+ Enable for IPC in MPU-only systems (Cortex-M with MPU).
292+ Disable if not using shared memory to save ~1-2KB ROM.
69293 endif
70294
71295 menuconfig RT_USING_LDSO
72296 bool "LDSO: dynamic load shared objects"
73297 depends on RT_USING_DFS_V2
74298 select RT_USING_PAGECACHE
75299 default y
300+ help
301+ Enable dynamic linker/loader for shared libraries and executables.
302+
303+ LDSO (LD.SO - Link editor, Shared Object) provides:
304+ - Dynamic linking of shared libraries (.so files)
305+ - Runtime loading of executables (ELF files)
306+ - Symbol resolution and relocation
307+ - Lazy binding for faster startup
308+
309+ Features:
310+ - Load executables from file system
311+ - Share library code between processes (saves RAM)
312+ - Update libraries without recompiling applications
313+ - Standard ELF binary support
314+
315+ Requirements:
316+ - DFS v2.0 for file system access
317+ - Page cache for performance
318+
319+ Use cases:
320+ - Running standard Linux binaries
321+ - Modular application architecture
322+ - Shared library usage
323+ - Dynamic plugin loading
324+
325+ Essential for RT-Smart user-space applications.
326+ ROM overhead: ~10-15KB for LDSO implementation.
76327
77328 if RT_USING_LDSO
78329 config ELF_DEBUG_ENABLE
79330 bool "Enable ldso debug"
80331 default n
332+ help
333+ Enable debugging output for dynamic linker/loader operations.
334+
335+ Debug information includes:
336+ - Library loading and unloading
337+ - Symbol resolution process
338+ - Relocation details
339+ - Memory mapping operations
340+
341+ Useful for:
342+ - Troubleshooting loading failures
343+ - Understanding dependency chains
344+ - Debugging symbol resolution issues
345+
346+ Disable in production for reduced log output and smaller ROM.
81347
82348 config ELF_LOAD_RANDOMIZE
83349 bool "Enable random load address"
84350 default n
351+ help
352+ Enable ASLR (Address Space Layout Randomization) for loaded binaries.
353+
354+ Security feature that randomizes:
355+ - Executable base address
356+ - Shared library load addresses
357+ - Stack and heap positions
358+
359+ Benefits:
360+ - Harder to exploit buffer overflows
361+ - Prevents return-to-libc attacks
362+ - Increases security against memory exploits
363+
364+ Overhead:
365+ - Slightly slower loading
366+ - More complex debugging (non-deterministic addresses)
367+
368+ Enable for security-critical applications.
369+ Disable for easier debugging or deterministic behavior.
85370 endif
86371
87372rsource "terminal/Kconfig"
0 commit comments