Skip to content

[REFACTOR] Introduce QNX Single Thread Logging#799

Open
minminlittleshrimp wants to merge 1 commit intomasterfrom
dlt_devel_single_thread_qnx_logging
Open

[REFACTOR] Introduce QNX Single Thread Logging#799
minminlittleshrimp wants to merge 1 commit intomasterfrom
dlt_devel_single_thread_qnx_logging

Conversation

@minminlittleshrimp
Copy link
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 <Minh.LuuQuang@vn.bosch.com>
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

1 participant