Changeset 2d11a7d8 in mainline for uspace/app/tester/thread/thread1.c


Ignore:
Timestamp:
2009-06-30T15:54:14Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c40f88
Parents:
db24058
Message:

tester framework rewrite (go from a menu-driven interface to command-line interface)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/thread/thread1.c

    rdb24058 r2d11a7d8  
    2828 */
    2929
    30 #define THREADS 5
     30#define THREADS  20
     31#define DELAY    10
    3132
    3233#include <atomic.h>
     
    4344{
    4445        thread_detach(thread_get_id());
    45 
    46         while (atomic_get(&finish)) {
    47                 if (!sh_quiet)
    48                         printf("%llu ", thread_get_id());
     46       
     47        while (atomic_get(&finish))
    4948                usleep(100000);
    50         }
     49       
    5150        atomic_inc(&threads_finished);
    5251}
    5352
    54 char * test_thread1(bool quiet)
     53char *test_thread1(void)
    5554{
    56         unsigned int i, total = 0;
    57         sh_quiet = quiet;
     55        unsigned int i;
     56        unsigned int total = 0;
    5857       
    5958        atomic_set(&finish, 1);
    6059        atomic_set(&threads_finished, 0);
    61 
    62         for (i = 0; i < THREADS; i++) { 
     60       
     61        TPRINTF("Creating threads");
     62        for (i = 0; i < THREADS; i++) {
    6363                if (thread_create(threadtest, NULL, "threadtest", NULL) < 0) {
    64                         if (!quiet)
    65                                 printf("Could not create thread %d\n", i);
     64                        TPRINTF("\nCould not create thread %u\n", i);
    6665                        break;
    6766                }
     67                TPRINTF(".");
    6868                total++;
    6969        }
    7070       
    71         if (!quiet)
    72                 printf("Running threads for 10 seconds...\n");
    73         sleep(10);
     71        TPRINTF("\nRunning threads for %u seconds...", DELAY);
     72        sleep(DELAY);
     73        TPRINTF("\n");
    7474       
    7575        atomic_set(&finish, 0);
    7676        while (atomic_get(&threads_finished) < total) {
    77                 if (!quiet)
    78                         printf("Threads left: %d\n", total - atomic_get(&threads_finished));
     77                TPRINTF("Threads left: %u\n", total - atomic_get(&threads_finished));
    7978                sleep(1);
    8079        }
Note: See TracChangeset for help on using the changeset viewer.