1 /******************************************************************************
3 * Copyright © International Business Machines Corp., 2008
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Use run_auto.sh script in current directory to build and run test.
28 * Use "-j" to enable jvm simulator.
36 *****************************************************************************/
42 #include <librttest.h>
43 pthread_mutex_t child_mutex
;
45 void* child_thread (void* arg
)
49 ret
= pthread_mutex_lock(&child_mutex
);
51 printf("child thread: Failed to lock child_mutex: %d\n", ret
);
53 printf("child_thread: got lock\n");
57 printf("child_thread: Trying to get lock 2nd time\n");
58 ret
= pthread_mutex_lock(&child_mutex
);
60 printf("child thread: Failed to lock child_mutex: %d\n", ret
);
62 printf("child_thread: got lock 2nd time !!\n");
67 int do_test(int argc
, char ** argv
)
69 pthread_mutexattr_t mutexattr
;
72 if (pthread_mutexattr_init(&mutexattr
) != 0) {
73 printf("Failed to init mutexattr\n");
75 if (pthread_mutexattr_setprotocol(&mutexattr
, PTHREAD_PRIO_INHERIT
) != 0) {
76 printf("Can't set protocol prio inherit\n");
78 if (pthread_mutexattr_getprotocol(&mutexattr
, &protocol
) != 0) {
79 printf("Can't get mutexattr protocol\n");
81 printf("protocol in mutexattr is %d\n", protocol
);
83 if ((retc
= pthread_mutex_init(&child_mutex
, &mutexattr
)) != 0) {
84 printf("Failed to init mutex: %d\n", retc
);
87 create_other_thread(child_thread
, NULL
);
93 #include "test-skeleton.c"