Skip to content

[REFACTOR] Introduce QNX Single Thread Logging#799

Merged
minminlittleshrimp merged 1 commit intomasterfrom
dlt_devel_single_thread_qnx_logging
Mar 5, 2026
Merged

[REFACTOR] Introduce QNX Single Thread Logging#799
minminlittleshrimp merged 1 commit intomasterfrom
dlt_devel_single_thread_qnx_logging

Conversation

@minminlittleshrimp
Copy link
Copy Markdown
Collaborator

  1. Pthread APIs in QNX follow POSIX standard, hence, to avoid undefined behaviors:
  • Return value from each API call will be handled
  • Manually allocate stack size for thread
  • Reduce thread queue to one for logging only to avoid unlimited threads creation
  • Use only 1 thread to handle logging, with stack size fixed to 12K (4K aligned)
  1. Injection callback:
  • Since only 1 thread is used, callback injection will now do infinity wait inside slogger2_callback
  1. Handle properly dlt thread in normal exit:
  • Add an atomic_bool for thread cancellation in normal main thread exit case.
  1. Handle slog2_thread heap memory:
  • slog2_thread is now allocated on HEAP, in case of failure or normal exit, free this HEAP allocated memory is required to prevent memory leak. During thread allocation on heap, the pointer stackaddr shall be round up to the nearest aligned memory address within 16K memory allocated.

Example: Heap 16K memory
|-------------|------------------------|
0x1003 0x2000-aligned MAX_MEM

MAX_MEM - 0x1003 = 16K
MAX_MEM - 0x2000 >= 12K

1. Pthread APIs in QNX follow POSIX standard,
hence, to avoid undefined behaviors:
- Return value from each API call will be handled
- Manually allocate stack size for thread
- Reduce thread queue to one for logging only to
  avoid unlimited threads creation
- Use only 1 thread to handle logging, with
  stack size fixed to 12K (4K aligned)

2. Injection callback:
- Since only 1 thread is used, callback injection
  will now do infinity wait inside slogger2_callback

3. Handle properly dlt thread in normal exit:
- Add an atomic_bool for thread cancellation in
  normal main thread exit case.

4. Handle slog2_thread heap memory:
- slog2_thread is now allocated on HEAP, in case of
  failure or normal exit, free this HEAP allocated
  memory is required to prevent memory leak. During
  thread allocation on heap, the pointer stackaddr
  shall be round up to the nearest aligned memory
  address within 16K memory allocated.

Example: Heap 16K memory
   |-------------|------------------------|
0x1003    0x2000-aligned               MAX_MEM

MAX_MEM - 0x1003 = 16K
MAX_MEM - 0x2000 >= 12K

Signed-off-by: LUU QUANG MINH <[email protected]>
Copy link
Copy Markdown
Collaborator

@lti9hc lti9hc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR was verified on project and stable now

@minminlittleshrimp minminlittleshrimp merged commit c45bdbe into master Mar 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dlt-daemon crashes on full filesystem

2 participants