1 /* This test is designed to see if a thread can be created with a time-slice.
2    No time-slice occurs, only the processing to check for time-slicing.  */
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 /* 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_basic_time_slice_application_define(void *first_unused_memory)
25 #endif
26 {
27 
28 UINT     status;
29 
30     /* Put system definition stuff in here, e.g. thread creates and other assorted
31        create information.  */
32 
33     status =  tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
34             first_unused_memory, TEST_STACK_SIZE_PRINTF,
35             16, 16, 1, TX_AUTO_START);
36 
37     /* Check for status.  */
38     if (status != TX_SUCCESS)
39     {
40 
41         printf("Running Thread Basic Time-Slice Test................................ ERROR #1\n");
42         test_control_return(1);
43     }
44 }
45 
46 
47 
48 /* Define the test threads.  */
49 
thread_0_entry(ULONG thread_input)50 static void    thread_0_entry(ULONG thread_input)
51 {
52 
53 
54     /* Inform user.  */
55     printf("Running Thread Basic Time-Slice Test................................ ");
56 
57     /* Enter into a forever loop.  */
58     while(1)
59     {
60 
61         /* Increment thread 0 counter.  */
62         thread_0_counter++;
63 
64         /* Determine if we are done.  */
65         if (tx_time_get() > 18)
66         {
67 
68             /* Successful Time-slice test.  */
69             printf("SUCCESS!\n");
70             test_control_return(0);
71         }
72     }
73 }
74