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
58
59 /* Inform user. */
60 printf("Running Thread Simple Sleep for 18 Ticks Test....................... ");
61
62 /* Clear the tick count. */
63 tx_time_set(0);
64
65 /* Sleep for 18 ticks. */
66 tx_thread_sleep(18);
67
68 /* Determine if the sleep was accurate. */
69 if ((tx_time_get() == 18) ||
70 (tx_time_get() == 19))
71 {
72
73 /* Successful Simple Sleep test. */
74 printf("SUCCESS!\n");
75 test_control_return(0);
76 }
77 else
78 {
79
80 /* Thread Simple Sleep error. */
81 printf("ERROR #2\n");
82 test_control_return(1);
83 }
84 }
85
86