Skip to content

Commit b2beb17

Browse files
authored
Merge pull request #449 from hnguyenHWI/master
Document GNU library compile flags for Linux and SMP Linux
2 parents 4fdc5dc + 20958dd commit b2beb17

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

ports/linux/gnu/readme_threadx.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ You should observe the compilation of sample_threadx.c (which is the demonstrati
3333
application) and linking with tx.a. The resulting file DEMO is a binary file
3434
that can be executed.
3535

36+
2.1 Includes
37+
38+
Notice that the demonstration Makefile includes defines for _GNU_SOURCE
39+
and TX_LINUX_MULTI_CORE. These are necessary to enable GNU/Linux-specific
40+
compatibility for ThreadX using the Linux kernel in multi-core devices,
41+
including the option to control processor affinity. See the GNU documentation
42+
on CPU affinity and Feature Test Macros for more information.
43+
44+
TX_LINUX_MULTI_CORE is necessary to enable code that constrains ThreadX to
45+
one core, to prevent unintended behavior when threads execute simultaneously
46+
across multiple cores. The enabled code configures CPU affinity, requiring
47+
the use of macros such as CPU_SET and functions such as sched_setaffinity.
48+
Access to these macros and functions (and the underlying types for the latter)
49+
are enabled via the definition of _GNU_SOURCE.
50+
51+
When building your own application, the _GNU_SOURCE and TX_LINUX_MULTI_CORE
52+
symbols can be defined by being passed to the compiler (e.g. -D_GNU_SOURCE) or
53+
in the optional user-defined ThreadX user define file tx_user.h. In the latter
54+
case, ensure that the symbol TX_INCLUDE_USER_DEFINE_FILE is defined, to instruct
55+
the tx_port.h header to include tx_user.h.
3656

3757
3. System Initialization
3858

ports_smp/linux/gnu/readme_threadx.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ You should observe the compilation of sample_threadx.c (which is the demonstrati
3333
application) and linking with tx.a. The resulting file DEMO is a binary file
3434
that can be executed.
3535

36+
2.1 Includes
37+
38+
Notice that the demonstration Makefile includes defines for _GNU_SOURCE
39+
and TX_LINUX_MULTI_CORE. These are necessary to enable GNU/Linux-specific
40+
compatibility for ThreadX using SMP with the Linux kernel in multi-core devices,
41+
including the option to control processor affinity. See the GNU documentation
42+
on CPU affinity and Feature Test Macros for more information.
43+
44+
TX_LINUX_MULTI_CORE is necessary to enable code that constrains ThreadX to
45+
one core, to prevent unintended behavior when threads execute simultaneously
46+
across multiple cores. The enabled code configures CPU affinity, requiring
47+
the use of macros such as CPU_SET and functions such as sched_setaffinity.
48+
Access to these macros and functions (and the underlying types for the latter)
49+
are enabled via the definition of _GNU_SOURCE.
50+
51+
When building your own application, the _GNU_SOURCE and TX_LINUX_MULTI_CORE
52+
symbols can be defined by being passed to the compiler (e.g. -D_GNU_SOURCE) or
53+
in the optional user-defined ThreadX user define file tx_user.h. In the latter
54+
case, ensure that the symbol TX_INCLUDE_USER_DEFINE_FILE is defined, to instruct
55+
the tx_port.h header to include tx_user.h.
3656

3757
3. System Initialization
3858

0 commit comments

Comments
 (0)