1 /* This test is designed to test a simple sleep for 18 ticks, with something in the
2    remaining field of the thread control block.  */
3 
4 #include   <stdio.h>
5 #include   "tx_api.h"
6 
7 //static unsigned long   thread_0_counter =  0;
8 static TX_THREAD       thread_0;
9 
10 
11 /* Define thread prototypes.  */
12 
13 static void    thread_0_entry(ULONG thread_input);
14 
15 
16 /* Prototype for test control return.  */
17 void  test_control_return(UINT status);
18 
19 
20 /* Define what the initial system looks like.  */
21 
22 #ifdef CTEST
test_application_define(void * first_unused_memory)23 void test_application_define(void *first_unused_memory)
24 #else
25 void    threadx_thread_simple_sleep_non_clear_application_define(void *first_unused_memory)
26 #endif
27 {
28 
29 UINT    status;
30 CHAR    *pointer;
31 
32     /* Put first available memory address into a character pointer.  */
33     pointer =  (CHAR *) first_unused_memory;
34 
35     /* Place a 1 in the thread control block to simulate a control block created in
36        random memory.  */
37     thread_0.tx_thread_timer.tx_timer_internal_re_initialize_ticks = 1;
38 
39     /* Put system definition stuff in here, e.g. thread creates and other assorted
40        create information.  */
41 
42     status =  tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
43             pointer, TEST_STACK_SIZE_PRINTF,
44             16, 16, 3, TX_AUTO_START);
45 
46     /* Check for status.  */
47     if (status != TX_SUCCESS)
48     {
49 
50         printf("Running Thread Sleep with non-zero TX_THREAD........................ ERROR #1\n");
51         test_control_return(1);
52     }
53 }
54 
55 
56 
57 /* Define the test threads.  */
58 
thread_0_entry(ULONG thread_input)59 static void    thread_0_entry(ULONG thread_input)
60 {
61 
62 
63     /* Inform user.  */
64     printf("Running Thread Sleep with non-zero TX_THREAD........................ ");
65 
66     /* Clear the tick count. */
67     tx_time_set(0);
68 
69     /* Sleep for 18 ticks.  */
70     tx_thread_sleep(9);
71     tx_thread_sleep(9);
72 
73     /* Determine if the sleep was accurate.  */
74     if ((tx_time_get() == 18) ||
75         (tx_time_get() == 19))
76     {
77 
78         /* Successful Simple Sleep test.  */
79         printf("SUCCESS!\n");
80         test_control_return(0);
81     }
82     else
83     {
84 
85         /* Thread Simple Sleep error.  */
86         printf("ERROR #2\n");
87         test_control_return(1);
88     }
89 }
90 
91