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