Skip to content

Commit 87e5110

Browse files
committed
Make queue max message size configurable
Summary ------- This commit fixes the issue #424 Details -------- - Add a the configuration option TX_QUEUE_MESSAGE_MAX_SIZE in the tx_api.h with default value set to TX_ULONG_16 to keep backword compatibility. - Update the txe_queue_create() to check on TX_QUEUE_MESSAGE_MAX_SIZE rather than TX_ULONG_16 as max message size. - Add a new unitary test to cover the new change.
1 parent 7ad78c4 commit 87e5110

File tree

9 files changed

+448
-7
lines changed

9 files changed

+448
-7
lines changed

common/inc/tx_api.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ extern "C" {
328328
#define TX_TIMER_TICKS_PER_SECOND (100UL)
329329
#endif
330330

331+
/* Define the default maximum message size in a queue. The default value is TX_16_ULONG, but may
332+
be customized in tx_user.h or as a compilation option. */
333+
334+
#ifndef TX_QUEUE_MESSAGE_MAX_SIZE
335+
#define TX_QUEUE_MESSAGE_MAX_SIZE TX_16_ULONG
336+
#endif
331337

332338
/* Event numbers 0 through 4095 are reserved by Azure RTOS. Specific event assignments are:
333339

common/inc/tx_user_sample.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@
117117
#define TX_TIMER_THREAD_PRIORITY ????
118118
*/
119119

120+
/* Define the maximum size of a message in the a queue. the Default value is TX_ULONG_16.
121+
the new value must be a multiple of ULONG. */
122+
123+
/*
124+
#define TX_QUEUE_MESSAGE_MAX_SIZE TX_ULONG_16
125+
*/
126+
120127
/* Define the common timer tick reference for use by other middleware components. The default
121128
value is 10ms (i.e. 100 ticks, defined in tx_api.h), but may be replaced by a port-specific
122129
version in tx_port.h or here.

common/src/txe_queue_create.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ TX_THREAD *thread_ptr;
178178
status = TX_SIZE_ERROR;
179179
}
180180

181-
/* Check for an invalid message size - greater than 16. */
182-
else if (message_size > TX_16_ULONG)
181+
/* Check for an invalid message size - greater than TX_QUEUE_MESSAGE_MAX_SIZE 16 by default. */
182+
else if (message_size > TX_QUEUE_MESSAGE_MAX_SIZE)
183183
{
184184

185185
/* Invalid message size specified. */

test/smp/cmake/regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(regression_test_cases
4747
${SOURCE_DIR}/threadx_queue_basic_one_word_test.c
4848
${SOURCE_DIR}/threadx_queue_basic_sixteen_word_test.c
4949
${SOURCE_DIR}/threadx_queue_basic_two_word_test.c
50+
${SOURCE_DIR}/threadx_queue_basic_max_message_size_test.c
5051
${SOURCE_DIR}/threadx_queue_empty_suspension_test.c
5152
${SOURCE_DIR}/threadx_queue_flush_no_suspension_test.c
5253
${SOURCE_DIR}/threadx_queue_flush_test.c

test/smp/regression/testcontrol.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ void threadx_queue_basic_two_word_application_define(void *);
185185
void threadx_queue_basic_four_word_application_define(void *);
186186
void threadx_queue_basic_eight_word_application_define(void *);
187187
void threadx_queue_basic_sixteen_word_application_define(void *);
188+
void threadx_queue_basic_max_message_size_application_define(void *);
188189
void threadx_queue_empty_suspension_application_define(void *);
189190
void threadx_queue_full_suspension_application_define(void *);
190191
void threadx_queue_suspension_timeout_application_define(void *);

test/tx/cmake/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ endif()
2222

2323
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
2424
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
25-
set(default_build_coverage "")
26-
set(disable_notify_callbacks_build -DTX_DISABLE_NOTIFY_CALLBACKS)
27-
set(stack_checking_build -DTX_ENABLE_STACK_CHECKING)
28-
set(stack_checking_rand_fill_build -DTX_ENABLE_STACK_CHECKING -DTX_ENABLE_RANDOM_NUMBER_STACK_FILLING)
29-
set(trace_build -DTX_ENABLE_EVENT_TRACE)
25+
set(default_build_coverage -DTX_QUEUE_MESSAGE_MAX_SIZE=32)
26+
set(disable_notify_callbacks_build -DTX_QUEUE_MESSAGE_MAX_SIZE=32 -DTX_DISABLE_NOTIFY_CALLBACKS)
27+
set(stack_checking_build -DTX_QUEUE_MESSAGE_MAX_SIZE=32 -DTX_ENABLE_STACK_CHECKING)
28+
set(stack_checking_rand_fill_build -DTX_QUEUE_MESSAGE_MAX_SIZE=32 -DTX_ENABLE_STACK_CHECKING -DTX_ENABLE_RANDOM_NUMBER_STACK_FILLING)
29+
set(trace_build -DTX_QUEUE_MESSAGE_MAX_SIZE=32 -DTX_ENABLE_EVENT_TRACE)
3030

3131
add_compile_options(
3232
-m32

test/tx/cmake/regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(regression_test_cases
4747
${SOURCE_DIR}/threadx_queue_basic_one_word_test.c
4848
${SOURCE_DIR}/threadx_queue_basic_sixteen_word_test.c
4949
${SOURCE_DIR}/threadx_queue_basic_two_word_test.c
50+
${SOURCE_DIR}/threadx_queue_basic_max_message_size_test.c
5051
${SOURCE_DIR}/threadx_queue_empty_suspension_test.c
5152
${SOURCE_DIR}/threadx_queue_flush_no_suspension_test.c
5253
${SOURCE_DIR}/threadx_queue_flush_test.c

test/tx/regression/testcontrol.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ void threadx_queue_basic_two_word_application_define(void *);
171171
void threadx_queue_basic_four_word_application_define(void *);
172172
void threadx_queue_basic_eight_word_application_define(void *);
173173
void threadx_queue_basic_sixteen_word_application_define(void *);
174+
void threadx_queue_basic_max_message_size_application_define(void *);
174175
void threadx_queue_empty_suspension_application_define(void *);
175176
void threadx_queue_full_suspension_application_define(void *);
176177
void threadx_queue_suspension_timeout_application_define(void *);
@@ -287,6 +288,7 @@ TEST_ENTRY test_control_tests[] =
287288
threadx_queue_basic_four_word_application_define,
288289
threadx_queue_basic_eight_word_application_define,
289290
threadx_queue_basic_sixteen_word_application_define,
291+
threadx_queue_basic_max_message_size_application_define,
290292
threadx_queue_empty_suspension_application_define,
291293
threadx_queue_full_suspension_application_define,
292294
threadx_queue_suspension_timeout_application_define,
@@ -1193,6 +1195,7 @@ void test_control_return(UINT status)
11931195

11941196
UINT old_posture = TX_INT_ENABLE;
11951197

1198+
printf("********** Running Queue Max Message Size Test (%u) ************** \n ", TX_QUEUE_MESSAGE_MAX_SIZE);
11961199

11971200
/* Save the status in a global. */
11981201
test_control_return_status = status;

0 commit comments

Comments
 (0)