Subversion Repositories HelenOS

Rev

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

Rev 3022 Rev 4055
Line 66... Line 66...
66
                slab_free(cache1, data1);
66
                slab_free(cache1, data1);
67
            if (data2)
67
            if (data2)
68
                slab_free(cache2, data2);
68
                slab_free(cache2, data2);
69
            break;
69
            break;
70
        }
70
        }
71
        memsetb((uintptr_t) data1, ITEM_SIZE, 0);
71
        memsetb(data1, ITEM_SIZE, 0);
72
        memsetb((uintptr_t) data2, ITEM_SIZE, 0);
72
        memsetb(data2, ITEM_SIZE, 0);
73
        *((void **) data1) = olddata1;
73
        *((void **) data1) = olddata1;
74
        *((void **) data2) = olddata2;
74
        *((void **) data2) = olddata2;
75
        olddata1 = data1;
75
        olddata1 = data1;
76
        olddata2 = data2;
76
        olddata2 = data2;
77
    } while (1);
77
    } while (1);
Line 98... Line 98...
98
        if (!data1) {
98
        if (!data1) {
99
            if (!quiet)
99
            if (!quiet)
100
                printf("Incorrect memory size - use another test.");
100
                printf("Incorrect memory size - use another test.");
101
            return;
101
            return;
102
        }
102
        }
103
        memsetb((uintptr_t) data1, ITEM_SIZE, 0);
103
        memsetb(data1, ITEM_SIZE, 0);
104
        *((void **) data1) = olddata1;
104
        *((void **) data1) = olddata1;
105
        olddata1 = data1;
105
        olddata1 = data1;
106
    }
106
    }
107
    while (1) {
107
    while (1) {
108
        data1 = slab_alloc(cache1, FRAME_ATOMIC);
108
        data1 = slab_alloc(cache1, FRAME_ATOMIC);
109
        if (!data1)
109
        if (!data1)
110
            break;
110
            break;
111
        memsetb((uintptr_t) data1, ITEM_SIZE, 0);
111
        memsetb(data1, ITEM_SIZE, 0);
112
        *((void **) data1) = olddata1;
112
        *((void **) data1) = olddata1;
113
        olddata1 = data1;
113
        olddata1 = data1;
114
    }
114
    }
115
   
115
   
116
    if (!quiet)
116
    if (!quiet)
Line 148... Line 148...
148
    mutex_lock(&starter_mutex);
148
    mutex_lock(&starter_mutex);
149
    condvar_wait(&thread_starter,&starter_mutex);
149
    condvar_wait(&thread_starter,&starter_mutex);
150
    mutex_unlock(&starter_mutex);
150
    mutex_unlock(&starter_mutex);
151
   
151
   
152
    if (!sh_quiet)
152
    if (!sh_quiet)
153
        printf("Starting thread #%llu...\n",THREAD->tid);
153
        printf("Starting thread #%" PRIu64 "...\n", THREAD->tid);
154
 
154
 
155
    /* Alloc all */
155
    /* Alloc all */
156
    if (!sh_quiet)
156
    if (!sh_quiet)
157
        printf("Thread #%llu allocating...\n", THREAD->tid);
157
        printf("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
158
   
158
   
159
    while (1) {
159
    while (1) {
160
        /* Call with atomic to detect end of memory */
160
        /* Call with atomic to detect end of memory */
161
        new = slab_alloc(thr_cache, FRAME_ATOMIC);
161
        new = slab_alloc(thr_cache, FRAME_ATOMIC);
162
        if (!new)
162
        if (!new)
Line 164... Line 164...
164
        *((void **) new) = data;
164
        *((void **) new) = data;
165
        data = new;
165
        data = new;
166
    }
166
    }
167
   
167
   
168
    if (!sh_quiet)
168
    if (!sh_quiet)
169
        printf("Thread #%llu releasing...\n", THREAD->tid);
169
        printf("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
170
   
170
   
171
    while (data) {
171
    while (data) {
172
        new = *((void **)data);
172
        new = *((void **)data);
173
        *((void **) data) = NULL;
173
        *((void **) data) = NULL;
174
        slab_free(thr_cache, data);
174
        slab_free(thr_cache, data);
175
        data = new;
175
        data = new;
176
    }
176
    }
177
   
177
   
178
    if (!sh_quiet)
178
    if (!sh_quiet)
179
        printf("Thread #%llu allocating...\n", THREAD->tid);
179
        printf("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
180
   
180
   
181
    while (1) {
181
    while (1) {
182
        /* Call with atomic to detect end of memory */
182
        /* Call with atomic to detect end of memory */
183
        new = slab_alloc(thr_cache, FRAME_ATOMIC);
183
        new = slab_alloc(thr_cache, FRAME_ATOMIC);
184
        if (!new)
184
        if (!new)
Line 186... Line 186...
186
        *((void **) new) = data;
186
        *((void **) new) = data;
187
        data = new;
187
        data = new;
188
    }
188
    }
189
   
189
   
190
    if (!sh_quiet)
190
    if (!sh_quiet)
191
        printf("Thread #%llu releasing...\n", THREAD->tid);
191
        printf("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
192
   
192
   
193
    while (data) {
193
    while (data) {
194
        new = *((void **)data);
194
        new = *((void **)data);
195
        *((void **) data) = NULL;
195
        *((void **) data) = NULL;
196
        slab_free(thr_cache, data);
196
        slab_free(thr_cache, data);
197
        data = new;
197
        data = new;
198
    }
198
    }
199
   
199
   
200
    if (!sh_quiet)
200
    if (!sh_quiet)
201
        printf("Thread #%llu finished\n", THREAD->tid);
201
        printf("Thread #%" PRIu64 " finished\n", THREAD->tid);
202
   
202
   
203
    slab_print_list();
203
    slab_print_list();
204
    semaphore_up(&thr_sem);
204
    semaphore_up(&thr_sem);
205
}
205
}
206
 
206
 
Line 214... Line 214...
214
   
214
   
215
    if (!quiet)
215
    if (!quiet)
216
        printf("Running stress test with size %d\n", size);
216
        printf("Running stress test with size %d\n", size);
217
   
217
   
218
    condvar_initialize(&thread_starter);
218
    condvar_initialize(&thread_starter);
219
    mutex_initialize(&starter_mutex);
219
    mutex_initialize(&starter_mutex, MUTEX_PASSIVE);
220
 
220
 
221
    thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
221
    thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
222
    semaphore_initialize(&thr_sem,0);
222
    semaphore_initialize(&thr_sem,0);
223
    for (i = 0; i < THREADS; i++) {  
223
    for (i = 0; i < THREADS; i++) {  
224
        if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) {
224
        if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) {