Subversion Repositories HelenOS-historic

Rev

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

Rev 1111 Rev 1113
Line 31... Line 31...
31
#include <stdio.h>
31
#include <stdio.h>
32
#include <unistd.h>
32
#include <unistd.h>
33
#include <stdlib.h>
33
#include <stdlib.h>
34
#include <ns.h>
34
#include <ns.h>
35
#include <thread.h>
35
#include <thread.h>
-
 
36
#include <psthread.h>
36
#include <futex.h>
37
#include <futex.h>
37
 
38
 
38
int a;
39
int a;
39
atomic_t ftx;
40
atomic_t ftx;
40
 
41
 
Line 250... Line 251...
250
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
251
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
251
             "Pong1", got_answer);
252
             "Pong1", got_answer);
252
    ipc_wait_for_call(&data, 0);
253
    ipc_wait_for_call(&data, 0);
253
}
254
}
254
 
255
 
-
 
256
static int ptest(void *arg)
255
 
257
{
-
 
258
    printf("Pseudo thread-1\n");
-
 
259
    ps_preempt();
-
 
260
    printf("Pseudo thread-2\n");
-
 
261
    ps_preempt();
-
 
262
    printf("Pseudo thread-3\n");
-
 
263
    ps_preempt();
-
 
264
    printf("Pseudo thread-4\n");
-
 
265
    ps_preempt();
-
 
266
    printf("Pseudo finish\n");
-
 
267
    return 0;  
-
 
268
}
256
 
269
 
257
int main(int argc, char *argv[])
270
int main(int argc, char *argv[])
258
{
271
{
-
 
272
    pstid_t ptid;
259
    int tid;
273
    int tid;
-
 
274
 
260
    version_print();
275
    version_print();
261
 
276
 
262
/*  test_printf(); */
277
/*  test_printf(); */
263
//  test_ping();
278
//  test_ping();
264
//  test_async_ipc();
279
//  test_async_ipc();
Line 271... Line 286...
271
    if (futex_down(&ftx) < 0)
286
    if (futex_down(&ftx) < 0)
272
        printf("Futex failed.\n");
287
        printf("Futex failed.\n");
273
    if (futex_up(&ftx) < 0)
288
    if (futex_up(&ftx) < 0)
274
        printf("Futex failed.\n");
289
        printf("Futex failed.\n");
275
 
290
 
-
 
291
    if ((tid = thread_create(utest, NULL, "utest") != -1)) {
-
 
292
        printf("Created thread tid=%d\n", tid);
-
 
293
    }
-
 
294
 
276
    if (futex_down(&ftx) < 0)
295
    if (futex_down(&ftx) < 0)
277
        printf("Futex failed.\n");
296
        printf("Futex failed.\n");
278
 
297
 
279
    if ((tid = thread_create(utest, NULL, "utest") != -1)) {
298
    if ((tid = thread_create(utest, NULL, "utest") != -1)) {
280
        printf("Created thread tid=%d\n", tid);
299
        printf("Created thread tid=%d\n", tid);
Line 286... Line 305...
286
        ;
305
        ;
287
       
306
       
288
    if (futex_up(&ftx) < 0)
307
    if (futex_up(&ftx) < 0)
289
        printf("Futex failed.\n");
308
        printf("Futex failed.\n");
290
 
309
 
-
 
310
    ptid = psthread_create(ptest, NULL);
-
 
311
    printf("Main thread-1\n");
-
 
312
    ps_preempt();
-
 
313
    printf("Main thread-2\n");
-
 
314
    ps_preempt();
-
 
315
    printf("main thread-3\n");
-
 
316
 
-
 
317
    ps_join(ptid);
-
 
318
    printf("Main exiting\n");
-
 
319
 
291
    printf("Main thread exiting.\n");
320
    printf("Main thread exiting.\n");
292
    return 0;
321
    return 0;
293
}
322
}