OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.threads/] [thread_check.c] - Blame information for rev 330

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/* Copyright (C) 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
2
 
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; either version 3 of the License, or
6
   (at your option) any later version.
7
 
8
   This program is distributed in the hope that it will be useful,
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
   GNU General Public License for more details.
12
 
13
   You should have received a copy of the GNU General Public License
14
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
   This file was written by Steve Munroe (sjmunroe@us.ibm.com). */
17
 
18
/* Test break points and single step on thread functions.  */
19
 
20
#include <string.h>
21
#include <unistd.h>
22
#include <pthread.h>
23
#include <stdlib.h>
24
#include <stdio.h>
25
#include <errno.h>
26
 
27
#define N       2
28
 
29
static void *
30
tf (void *arg)
31
{
32
    int n = (int) (long int) arg;
33
    char number[160];
34
    int unslept = 10;
35
 
36
    sprintf(number, "tf(%ld): begin", (long)arg);
37
    puts (number);
38
 
39
    while (unslept > 0)
40
        unslept = sleep(unslept);
41
 
42
    sprintf(number, "tf(%ld): end", (long)arg);
43
    puts (number);
44
    return NULL;
45
}
46
 
47
int main (int argc, char *argv[])
48
{
49
    int n;
50
    int unslept = 2;
51
    pthread_t th[N];
52
 
53
    for (n = 0; n < N; ++n)
54
    if (pthread_create (&th[n], NULL, tf, (void *) (long int) n) != 0)
55
    {
56
        while (unslept > 0)
57
           unslept = sleep(2);
58
        puts ("create failed");
59
        exit (1);
60
    }
61
 
62
    puts("after create");
63
 
64
    for (n = 0; n < N; ++n)
65
    if (pthread_join (th[n], NULL) != 0)
66
    {
67
        puts ("join failed");
68
        exit (1);
69
    }
70
 
71
    puts("after join");
72
    return 0;
73
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.