Subversion Repositories HelenOS

Rev

Rev 2216 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2216 Rev 2229
Line 31... Line 31...
31
 
31
 
32
#include <atomic.h>
32
#include <atomic.h>
33
#include <thread.h>
33
#include <thread.h>
34
#include <stdio.h>
34
#include <stdio.h>
35
#include <unistd.h>
35
#include <unistd.h>
-
 
36
#include <futex.h>
36
#include "../tester.h"
37
#include "../tester.h"
37
 
38
 
38
static atomic_t finish;
39
static atomic_t finish;
39
static atomic_t threads_finished;
40
static atomic_t threads_finished;
40
static bool sh_quiet;
41
static bool sh_quiet;
41
 
42
 
-
 
43
static atomic_t srlz = FUTEX_INITIALIZER;
-
 
44
 
42
static void threadtest(void *data)
45
static void threadtest(void *data)
43
{
46
{
44
    thread_detach(thread_get_id());
47
    thread_detach(thread_get_id());
45
 
48
 
46
    while (atomic_get(&finish)) {
49
    while (atomic_get(&finish)) {
47
        if (!sh_quiet)
50
        if (!sh_quiet) {
-
 
51
            futex_down(&srlz);
48
            printf("%llu ", thread_get_id());
52
            printf("%llu ", thread_get_id());
-
 
53
            futex_up(&srlz);
-
 
54
        }
49
        usleep(100000);
55
        usleep(100000);
50
    }
56
    }
51
    atomic_inc(&threads_finished);
57
    atomic_inc(&threads_finished);
52
}
58
}
53
 
59
 
Line 66... Line 72...
66
            break;
72
            break;
67
        }
73
        }
68
        total++;
74
        total++;
69
    }
75
    }
70
   
76
   
71
    if (!quiet)
77
    if (!quiet) {
-
 
78
        futex_down(&srlz);
72
        printf("Running threads for 10 seconds...\n");
79
        printf("Running threads for 10 seconds...\n");
-
 
80
        futex_up(&srlz);
-
 
81
    }
73
    sleep(10);
82
    sleep(10);
74
   
83
   
75
    atomic_set(&finish, 0);
84
    atomic_set(&finish, 0);
76
    while (atomic_get(&threads_finished) < total) {
85
    while (atomic_get(&threads_finished) < total) {
77
        if (!quiet)
86
        if (!quiet)