Changeset cb01e1e in mainline for kernel/test/thread/thread1.c


Ignore:
Timestamp:
2009-04-04T00:26:27Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a85aebd
Parents:
171f9a1
Message:

use global variable and a macro for silencing tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/thread/thread1.c

    r171f9a1 rcb01e1e  
    3737#include <arch.h>
    3838
    39 #define THREADS 5
     39#define THREADS  5
    4040
    4141static atomic_t finish;
    4242static atomic_t threads_finished;
    43 static bool sh_quiet;
    4443
    4544static void threadtest(void *data)
    4645{
    47         thread_detach(THREAD); 
    48 
     46        thread_detach(THREAD);
     47       
    4948        while (atomic_get(&finish)) {
    50                 if (!sh_quiet)
    51                         printf("%" PRIu64 " ", THREAD->tid);
     49                TPRINTF("%" PRIu64 " ", THREAD->tid);
    5250                thread_usleep(100000);
    5351        }
     
    5553}
    5654
    57 char * test_thread1(bool quiet)
     55char *test_thread1(void)
    5856{
    5957        unsigned int i, total = 0;
    60         sh_quiet = quiet;
    6158       
    6259        atomic_set(&finish, 1);
    6360        atomic_set(&threads_finished, 0);
    64 
     61       
    6562        for (i = 0; i < THREADS; i++) { 
    6663                thread_t *t;
    6764                if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
    68                         if (!quiet)
    69                                 printf("Could not create thread %d\n", i);
     65                        TPRINTF("Could not create thread %d\n", i);
    7066                        break;
    7167                }
     
    7470        }
    7571       
    76         if (!quiet)
    77                 printf("Running threads for 10 seconds...\n");
     72        TPRINTF("Running threads for 10 seconds...\n");
    7873        thread_sleep(10);
    7974       
    8075        atomic_set(&finish, 0);
    8176        while (atomic_get(&threads_finished) < ((long) total)) {
    82                 if (!quiet)
    83                         printf("Threads left: %d\n", total - atomic_get(&threads_finished));
     77                TPRINTF("Threads left: %d\n", total - atomic_get(&threads_finished));
    8478                thread_sleep(1);
    8579        }
Note: See TracChangeset for help on using the changeset viewer.