Subversion Repositories HelenOS

Rev

Rev 3424 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3424 Rev 4377
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#if (defined(ia32) || defined(amd64) || defined(ia32xen))
-
 
30
 
-
 
31
#include <print.h>
29
#include <print.h>
32
#include <debug.h>
30
#include <debug.h>
33
 
31
 
34
#include <test.h>
32
#include <test.h>
35
#include <atomic.h>
33
#include <atomic.h>
36
#include <proc/thread.h>
34
#include <proc/thread.h>
37
#include <time/delay.h>
35
#include <time/delay.h>
38
 
36
 
39
#include <arch.h>
37
#include <arch.h>
40
 
38
 
41
#define THREADS     25
39
#define THREADS   25
42
#define DELAY       10000L
40
#define DELAY     10000L
43
#define ATTEMPTS        5
41
#define ATTEMPTS  5
44
 
42
 
45
static atomic_t threads_ok;
43
static atomic_t threads_ok;
46
static atomic_t threads_fault;
44
static atomic_t threads_fault;
47
static waitq_t can_start;
45
static waitq_t can_start;
48
static bool sh_quiet;
-
 
49
 
-
 
50
 
46
 
51
static void testit1(void *data)
47
static void testit1(void *data)
52
{
48
{
53
    int i;
49
    int i;
54
    int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
50
    int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
55
    int after_arg __attribute__((aligned(16)));
51
    int after_arg __attribute__((aligned(16)));
56
 
52
   
57
    thread_detach(THREAD);
53
    thread_detach(THREAD);
58
   
54
   
59
    waitq_sleep(&can_start);
55
    waitq_sleep(&can_start);
60
 
56
   
61
    for (i = 0; i < ATTEMPTS; i++) {
57
    for (i = 0; i < ATTEMPTS; i++) {
62
        asm volatile (
58
        asm volatile (
63
            "movlpd %0, %%xmm2\n"
59
            "movlpd %[arg], %%xmm2\n"
64
            : "=m" (arg)
60
            : [arg] "=m" (arg)
65
        );
61
        );
66
 
62
       
67
        delay(DELAY);
63
        delay(DELAY);
68
        asm volatile (
64
        asm volatile (
69
            "movlpd %%xmm2, %0\n"
65
            "movlpd %%xmm2, %[after_arg]\n"
70
            : "=m" (after_arg)
66
            : [after_arg] "=m" (after_arg)
71
        );
67
        );
72
       
68
       
73
        if (arg != after_arg) {
69
        if (arg != after_arg) {
74
            if (!sh_quiet)
-
 
75
                printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
70
            TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
76
            atomic_inc(&threads_fault);
71
            atomic_inc(&threads_fault);
77
            break;
72
            break;
78
        }
73
        }
79
    }
74
    }
80
    atomic_inc(&threads_ok);
75
    atomic_inc(&threads_ok);
Line 87... Line 82...
87
    int after_arg __attribute__((aligned(16)));
82
    int after_arg __attribute__((aligned(16)));
88
   
83
   
89
    thread_detach(THREAD);
84
    thread_detach(THREAD);
90
   
85
   
91
    waitq_sleep(&can_start);
86
    waitq_sleep(&can_start);
92
 
87
   
93
    for (i = 0; i < ATTEMPTS; i++) {
88
    for (i = 0; i < ATTEMPTS; i++) {
94
        asm volatile (
89
        asm volatile (
95
            "movlpd %0, %%xmm2\n"
90
            "movlpd %[arg], %%xmm2\n"
96
            : "=m" (arg)
91
            : [arg] "=m" (arg)
97
        );
92
        );
98
 
93
       
99
        scheduler();
94
        scheduler();
100
        asm volatile (
95
        asm volatile (
101
            "movlpd %%xmm2, %0\n"
96
            "movlpd %%xmm2, %[after_arg]\n"
102
            : "=m" (after_arg)
97
            : [after_arg] "=m" (after_arg)
103
        );
98
        );
104
       
99
       
105
        if (arg != after_arg) {
100
        if (arg != after_arg) {
106
            if (!sh_quiet)
-
 
107
                printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
101
            TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
108
            atomic_inc(&threads_fault);
102
            atomic_inc(&threads_fault);
109
            break;
103
            break;
110
        }
104
        }
111
    }
105
    }
112
    atomic_inc(&threads_ok);
106
    atomic_inc(&threads_ok);
113
}
107
}
114
 
108
 
115
 
-
 
116
char * test_sse1(bool quiet)
109
char *test_sse1(void)
117
{
110
{
118
    unsigned int i, total = 0;
111
    unsigned int i, total = 0;
119
    sh_quiet = quiet;
-
 
120
   
112
   
121
    waitq_initialize(&can_start);
113
    waitq_initialize(&can_start);
122
    atomic_set(&threads_ok, 0);
114
    atomic_set(&threads_ok, 0);
123
    atomic_set(&threads_fault, 0);
115
    atomic_set(&threads_fault, 0);
124
   
116
   
125
    if (!quiet)
-
 
126
        printf("Creating %u threads... ", 2 * THREADS);
117
    TPRINTF("Creating %u threads... ", 2 * THREADS);
127
 
118
   
128
    for (i = 0; i < THREADS; i++) {
119
    for (i = 0; i < THREADS; i++) {
129
        thread_t *t;
120
        thread_t *t;
130
       
121
       
131
        if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
122
        if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
132
            if (!quiet)
-
 
133
                printf("could not create thread %u\n", 2 * i);
123
            TPRINTF("could not create thread %u\n", 2 * i);
134
            break;
124
            break;
135
        }
125
        }
136
        thread_ready(t);
126
        thread_ready(t);
137
        total++;
127
        total++;
138
       
128
       
139
        if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
129
        if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
140
            if (!quiet)
-
 
141
                printf("could not create thread %u\n", 2 * i + 1);
130
            TPRINTF("could not create thread %u\n", 2 * i + 1);
142
            break;
131
            break;
143
        }
132
        }
144
        thread_ready(t);
133
        thread_ready(t);
145
        total++;
134
        total++;
146
    }
135
    }
147
   
136
   
148
    if (!quiet)
-
 
149
        printf("ok\n");
137
    TPRINTF("ok\n");
150
       
138
   
151
    thread_sleep(1);
139
    thread_sleep(1);
152
    waitq_wakeup(&can_start, WAKEUP_ALL);
140
    waitq_wakeup(&can_start, WAKEUP_ALL);
153
   
141
   
154
    while (atomic_get(&threads_ok) != (long) total) {
142
    while (atomic_get(&threads_ok) != (long) total) {
155
        if (!quiet)
-
 
156
            printf("Threads left: %d\n", total - atomic_get(&threads_ok));
143
        TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
157
        thread_sleep(1);
144
        thread_sleep(1);
158
    }
145
    }
159
   
146
   
160
    if (atomic_get(&threads_fault) == 0)
147
    if (atomic_get(&threads_fault) == 0)
161
        return NULL;
148
        return NULL;
162
   
149
   
163
    return "Test failed";
150
    return "Test failed";
164
}
151
}
165
 
-
 
166
#endif
-