Subversion Repositories HelenOS-historic

Rev

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

Rev 1128 Rev 1129
Line 37... Line 37...
37
#include <futex.h>
37
#include <futex.h>
38
 
38
 
39
int a;
39
int a;
40
atomic_t ftx;
40
atomic_t ftx;
41
 
41
 
-
 
42
int __thread tls_prom;
-
 
43
 
42
extern void utest(void *arg);
44
extern void utest(void *arg);
43
void utest(void *arg)
45
void utest(void *arg)
44
{
46
{
45
    printf("Uspace thread started.\n");
47
    printf("Uspace thread started.\n");
46
    if (futex_down(&ftx) < 0)
48
    if (futex_down(&ftx) < 0)
Line 253... Line 255...
253
    ipc_wait_for_call(&data, 0);
255
    ipc_wait_for_call(&data, 0);
254
}
256
}
255
 
257
 
256
static int ptest(void *arg)
258
static int ptest(void *arg)
257
{
259
{
-
 
260
    tls_prom = -1;
258
    printf("Pseudo thread stage1.\n");
261
    printf("Pseudo thread stage%d.\n", -tls_prom);
-
 
262
    tls_prom = -2;
259
    psthread_schedule_next();
263
    psthread_schedule_next();
260
    printf("Pseudo thread stage2.\n");
264
    printf("Pseudo thread stage%d.\n", -tls_prom);
-
 
265
    tls_prom = -3;
261
    psthread_schedule_next();
266
    psthread_schedule_next();
262
    printf("Pseudo thread stage3.\n");
267
    printf("Pseudo thread stage%d\n", -tls_prom);
263
    psthread_schedule_next();
268
    psthread_schedule_next();
264
    printf("Pseudo thread stage4.\n");
269
    printf("Pseudo thread stage4.\n");
265
    psthread_schedule_next();
270
    psthread_schedule_next();
266
    printf("Pseudo thread exiting.\n");
271
    printf("Pseudo thread exiting.\n");
267
    return 0;  
272
    return 0;  
Line 288... Line 293...
288
    if (futex_up(&ftx) < 0)
293
    if (futex_up(&ftx) < 0)
289
        printf("Futex failed.\n");
294
        printf("Futex failed.\n");
290
 
295
 
291
    if (futex_down(&ftx) < 0)
296
    if (futex_down(&ftx) < 0)
292
        printf("Futex failed.\n");
297
        printf("Futex failed.\n");
293
 
298
/*
294
    if ((tid = thread_create(utest, NULL, "utest")) != -1) {
299
    if ((tid = thread_create(utest, NULL, "utest")) != -1) {
295
        printf("Created thread tid=%d\n", tid);
300
        printf("Created thread tid=%d\n", tid);
296
    }
301
    }
297
 
302
 
298
    if ((tid = thread_create(utest, NULL, "utest")) != -1) {
303
    if ((tid = thread_create(utest, NULL, "utest")) != -1) {
299
        printf("Created thread tid=%d\n", tid);
304
        printf("Created thread tid=%d\n", tid);
300
    }
305
    }
301
 
306
*/
302
    int i;
307
    int i;
303
   
308
   
304
    for (i = 0; i < 50000000; i++)
309
    for (i = 0; i < 50000000; i++)
305
        ;
310
        ;
306
       
311
       
307
    if (futex_up(&ftx) < 0)
312
    if (futex_up(&ftx) < 0)
308
        printf("Futex failed.\n");
313
        printf("Futex failed.\n");
309
 
314
 
-
 
315
 
-
 
316
    printf("Creating pathread\n");
-
 
317
    tls_prom = 1;
310
    ptid = psthread_create(ptest, NULL);
318
    ptid = psthread_create(ptest, NULL);
311
    printf("Main thread stage1.\n");
319
    printf("Main thread stage%d\n",tls_prom);
-
 
320
    tls_prom = 2;
312
    psthread_schedule_next();;
321
    psthread_schedule_next();;
313
    printf("Main thread stage2.\n");
322
    printf("Main thread stage%d\n", tls_prom);
-
 
323
    tls_prom = 3;
314
    psthread_schedule_next();;
324
    psthread_schedule_next();;
315
    printf("Main thread stage3.\n");
325
    printf("Main thread stage%d\n", tls_prom);
316
 
326
 
317
    psthread_join(ptid);
327
    psthread_join(ptid);
318
 
328
 
319
    printf("Main thread exiting.\n");
329
    printf("Main thread exiting.\n");
320
    return 0;
330
    return 0;