Subversion Repositories HelenOS

Rev

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

Rev 4343 Rev 4348
Line 58... Line 58...
58
}
58
}
59
 
59
 
60
static atomic_t threads_ok;
60
static atomic_t threads_ok;
61
static atomic_t threads_fault;
61
static atomic_t threads_fault;
62
static waitq_t can_start;
62
static waitq_t can_start;
63
static bool sh_quiet;
-
 
64
 
63
 
65
static void e(void *data)
64
static void e(void *data)
66
{
65
{
67
    int i;
66
    int i;
68
    double e, d, le, f;
67
    double e, d, le, f;
Line 80... Line 79...
80
            le = e;
79
            le = e;
81
            e = e + 1 / d;
80
            e = e + 1 / d;
82
        }
81
        }
83
       
82
       
84
        if ((int) (100000000 * e) != E_10e8) {
83
        if ((int) (100000000 * e) != E_10e8) {
85
            if (!sh_quiet)
-
 
86
                printf("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
84
            TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
87
            atomic_inc(&threads_fault);
85
            atomic_inc(&threads_fault);
88
            break;
86
            break;
89
        }
87
        }
90
    }
88
    }
91
    atomic_inc(&threads_ok);
89
    atomic_inc(&threads_ok);
Line 114... Line 112...
114
            lpi = pi;
112
            lpi = pi;
115
            pi = 2 * n * ad;
113
            pi = 2 * n * ad;
116
        }
114
        }
117
       
115
       
118
        if ((int) (100000000 * pi) != PI_10e8) {
116
        if ((int) (100000000 * pi) != PI_10e8) {
119
            if (!sh_quiet)
-
 
120
                printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
117
            TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
121
            atomic_inc(&threads_fault);
118
            atomic_inc(&threads_fault);
122
            break;
119
            break;
123
        }
120
        }
124
    }
121
    }
125
    atomic_inc(&threads_ok);
122
    atomic_inc(&threads_ok);
126
}
123
}
127
 
124
 
128
char * test_fpu1(bool quiet)
125
char *test_fpu1(void)
129
{
126
{
130
    unsigned int i, total = 0;
127
    unsigned int i, total = 0;
131
    sh_quiet = quiet;
-
 
132
   
128
   
133
    waitq_initialize(&can_start);
129
    waitq_initialize(&can_start);
134
    atomic_set(&threads_ok, 0);
130
    atomic_set(&threads_ok, 0);
135
    atomic_set(&threads_fault, 0);
131
    atomic_set(&threads_fault, 0);
136
   
132
   
137
    if (!quiet)
-
 
138
        printf("Creating %u threads... ", 2 * THREADS);
133
    TPRINTF("Creating %u threads... ", 2 * THREADS);
139
   
134
   
140
    for (i = 0; i < THREADS; i++) {  
135
    for (i = 0; i < THREADS; i++) {
141
        thread_t *t;
136
        thread_t *t;
142
       
137
       
143
        if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) {
138
        if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) {
144
            if (!quiet)
-
 
145
                printf("could not create thread %u\n", 2 * i);
139
            TPRINTF("could not create thread %u\n", 2 * i);
146
            break;
140
            break;
147
        }
141
        }
148
        thread_ready(t);
142
        thread_ready(t);
149
        total++;
143
        total++;
150
       
144
       
151
        if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) {
145
        if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) {
152
            if (!quiet)
-
 
153
                printf("could not create thread %u\n", 2 * i + 1);
146
            TPRINTF("could not create thread %u\n", 2 * i + 1);
154
            break;
147
            break;
155
        }
148
        }
156
        thread_ready(t);
149
        thread_ready(t);
157
        total++;
150
        total++;
158
    }
151
    }
159
   
152
   
160
    if (!quiet)
-
 
161
        printf("ok\n");
153
    TPRINTF("ok\n");
162
   
154
   
163
    thread_sleep(1);
155
    thread_sleep(1);
164
    waitq_wakeup(&can_start, WAKEUP_ALL);
156
    waitq_wakeup(&can_start, WAKEUP_ALL);
165
   
157
   
166
    while (atomic_get(&threads_ok) != (long) total) {
158
    while (atomic_get(&threads_ok) != (long) total) {
167
        if (!quiet)
-
 
168
            printf("Threads left: %d\n", total - atomic_get(&threads_ok));
159
        TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
169
        thread_sleep(1);
160
        thread_sleep(1);
170
    }
161
    }
171
   
162
   
172
    if (atomic_get(&threads_fault) == 0)
163
    if (atomic_get(&threads_fault) == 0)
173
        return NULL;
164
        return NULL;