diff options
| author | Frédéric Desbiens <[email protected]> | 2026-03-06 19:27:49 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-06 19:27:49 +0100 |
| commit | 3726d7906b4808bfec7855fc088e073199df9120 (patch) | |
| tree | 8789bfd03d1d49e1967e80d04aa4ff606fda43eb /test/smp/regression/threadx_thread_preemption_change_test.c | |
| parent | 4b6e8100d932a3a67b34c6eb17f84f3bffb9e2ae (diff) | |
| parent | c3259a216026372e3833dd8996a68f77e8595fbd (diff) | |
Merge pull request #510 from eclipse-threadx/devv6.5.0.202601_rel
Merge changes ahead of the v6.5.0.202601 release
Diffstat (limited to 'test/smp/regression/threadx_thread_preemption_change_test.c')
| -rw-r--r-- | test/smp/regression/threadx_thread_preemption_change_test.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/test/smp/regression/threadx_thread_preemption_change_test.c b/test/smp/regression/threadx_thread_preemption_change_test.c index a16b2633..5f9726c0 100644 --- a/test/smp/regression/threadx_thread_preemption_change_test.c +++ b/test/smp/regression/threadx_thread_preemption_change_test.c @@ -51,8 +51,8 @@ CHAR *pointer; /* Put system definition stuff in here, e.g. thread creates and other assorted create information. */ - status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 15, TX_NO_TIME_SLICE, TX_AUTO_START); pointer = pointer + TEST_STACK_SIZE_PRINTF; @@ -66,8 +66,8 @@ CHAR *pointer; #ifndef TX_DISABLE_PREEMPTION_THRESHOLD /* skip this test and pretend it passed */ - status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 15, 15, TX_NO_TIME_SLICE, TX_AUTO_START); pointer = pointer + TEST_STACK_SIZE_PRINTF; @@ -79,8 +79,8 @@ CHAR *pointer; test_control_return(1); } - status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 14, 14, TX_NO_TIME_SLICE, TX_DONT_START); pointer = pointer + TEST_STACK_SIZE_PRINTF; @@ -126,7 +126,7 @@ UINT i; /* Increment thread 0 counter. */ thread_0_counter++; - /* Resume thread 1, which has a higher priority. Preemption is disabled + /* Resume thread 1, which has a higher priority. Preemption is disabled though so thread 1 should not run yet. */ status = tx_thread_resume(&thread_1); @@ -169,7 +169,7 @@ UINT i; } /* Change the preemption threshold back to 15. */ - status = tx_thread_preemption_change(&thread_0, 15, &old_threshold); + status = tx_thread_preemption_change(&thread_0, 15, &old_threshold); /* Check status and run counters of other threads. */ if ((status != TX_SUCCESS) || (thread_1_counter != 1) || (thread_2_counter != 0) || @@ -181,7 +181,7 @@ UINT i; test_control_return(1); } - /* Resume thread 2. This should preempt because it is priority 14 and the + /* Resume thread 2. This should preempt because it is priority 14 and the current preemption threshold is 15. */ status = tx_thread_resume(&thread_2); @@ -194,16 +194,16 @@ UINT i; test_control_return(1); } - /* At this point, we are going to loop through preemption changes that result in + /* At this point, we are going to loop through preemption changes that result in preemption. */ for (i = 0; i < (TX_THREAD_EXECUTE_LOG_SIZE*3); i++) { /* Change the preemption threshold back to 14. */ - status = tx_thread_preemption_change(&thread_0, 14, &old_threshold); + status = tx_thread_preemption_change(&thread_0, 14, &old_threshold); /* Check status. */ - if (status != TX_SUCCESS) + if (status != TX_SUCCESS) { /* Thread error. */ @@ -213,7 +213,7 @@ UINT i; /* Resume thread 2 again. */ status = tx_thread_resume(&thread_2); - + /* Check status an thread 2 run counter. */ if ((status != TX_SUCCESS) && (thread_2_counter != (i+1))) { @@ -222,9 +222,9 @@ UINT i; printf("ERROR #11\n"); test_control_return(1); } - + /* Change the preemption threshold back to 15 to allow thread 2 to run. */ - status = tx_thread_preemption_change(&thread_0, 15, &old_threshold); + status = tx_thread_preemption_change(&thread_0, 15, &old_threshold); /* Check status an thread 2 run counter. */ if ((status != TX_SUCCESS) && (thread_2_counter != (i+2))) @@ -237,21 +237,21 @@ UINT i; } /* Change the priority of threads 0 and 1. */ - status = tx_thread_priority_change(&thread_0, 7, &old_threshold); - status += tx_thread_priority_change(&thread_1, 5, &old_threshold); + status = tx_thread_priority_change(&thread_0, 7, &old_threshold); + status += tx_thread_priority_change(&thread_1, 5, &old_threshold); /* Check status. */ - if (status != TX_SUCCESS) + if (status != TX_SUCCESS) { /* Thread error. */ printf("ERROR #13\n"); test_control_return(1); - } + } /* Change the preemption-threshold of this thread. */ status = tx_thread_preemption_change(&thread_0, 0, &old_threshold); - + /* Check status. */ if ((status != TX_SUCCESS) || (old_threshold != 7)) { @@ -259,29 +259,29 @@ UINT i; /* Thread error. */ printf("ERROR #14\n"); test_control_return(1); - } - + } + /* Get the mutex that has priority inheritance. */ status = tx_mutex_get(&mutex_0, TX_WAIT_FOREVER); /* Check status. */ - if (status != TX_SUCCESS) + if (status != TX_SUCCESS) { /* Thread error. */ printf("ERROR #15\n"); test_control_return(1); - } - + } + /* Resume thread 1 so that it can suspend on the mutex and automatically raise its priority. */ tx_thread_resume(&thread_1); - + /* Self suspend so that thread 1 and run. */ tx_thread_suspend(&thread_0); - + /* Restore the preemption-threshold of this thread. */ status = tx_thread_preemption_change(&thread_0, old_threshold, &old_threshold); - + /* Check status. */ if ((status != TX_SUCCESS) || (old_threshold != 0) || (thread_0.tx_thread_priority != 5) || (thread_0.tx_thread_preempt_threshold != 5)) { @@ -289,7 +289,7 @@ UINT i; /* Thread error. */ printf("ERROR #16\n"); test_control_return(1); - } + } /* Ensure thread 0's entries in these lists were removed. */ if (_tx_thread_preempted_maps[0] != 0 || @@ -302,7 +302,7 @@ UINT i; } /* Let thread 1 run again so it can release the mutex and undo the priority inheritance. */ - status = tx_mutex_put(&mutex_0); + status = tx_mutex_put(&mutex_0); /* Check status. */ if ((status != TX_SUCCESS) || (thread_0.tx_thread_priority != 7) || (thread_0.tx_thread_preempt_threshold != 7)) @@ -311,7 +311,7 @@ UINT i; /* Thread error. */ printf("ERROR #18\n"); test_control_return(1); - } + } /* Test direct call to the thread preemption change routine with a threshold greater than the current priority. */ status = _tx_thread_preemption_change(&thread_0, 8, &old_threshold); @@ -345,7 +345,7 @@ UINT old_threshold; /* Self suspend after initial run. */ tx_thread_suspend(&thread_1); - + /* Increment the thread counter. */ thread_1_counter++; @@ -359,7 +359,7 @@ UINT old_threshold; tx_mutex_get(&mutex_0, TX_WAIT_FOREVER); /* Release the mutex. */ - tx_mutex_put(&mutex_0); + tx_mutex_put(&mutex_0); } @@ -368,10 +368,10 @@ static void thread_2_entry(ULONG thread_input) while(1) { - + /* Increment thread counter. */ thread_2_counter++; - + /* Self suspend. */ tx_thread_suspend(&thread_2); } |
