1/****************************************************************************** 2 * 3 * Copyright © International Business Machines Corp., 2005, 2008 4 * 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. 9 * 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. 14 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 * NAME 20 * testpi-0.c 21 * 22 * DESCRIPTION 23 * This testcase checks whether priority inheritance support is present 24 * in the running kernel 25 * 26 * USAGE: 27 * Use run_auto.sh script in current directory to build and run test. 28 * 29 * AUTHOR 30 * 31 * 32 * HISTORY 33 * 2010-04-22 Code cleanup by Gowrishankar (gowrishankar.m@in.ibm.com) 34 * 35 * 36 *****************************************************************************/ 37 38#include <stdio.h> 39#include <stdlib.h> 40#include <string.h> 41#include <sched.h> 42#include <pthread.h> 43#include <sys/types.h> 44#include <unistd.h> 45#include <librttest.h> 46 47void usage(void) 48{ 49 rt_help(); 50 printf("testpi-0 specific options:\n"); 51 printf("testpi-0 doesn't require any commandline options\n"); 52} 53 54int parse_args(int c, char *v) 55{ 56 57 int handled = 1; 58 switch (c) { 59 case 'h': 60 usage(); 61 exit(0); 62 default: 63 handled = 0; 64 break; 65 } 66 return handled; 67} 68 69/* 70 * Test pthread creation at different thread priorities. 71 */ 72int main(int argc, char *argv[]) 73{ 74 char *pathbuf; 75 size_t n; 76 77 rt_init("h", parse_args, argc, argv); 78 79 n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t) 0); 80 pathbuf = malloc(n); 81 if (!pathbuf) 82 abort(); 83 confstr(_CS_GNU_LIBC_VERSION, pathbuf, n); 84 85 printf("LIBC_VERSION: %s\n", pathbuf); 86 free(pathbuf); 87 88 n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0); 89 pathbuf = malloc(n); 90 if (!pathbuf) 91 abort(); 92 confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, n); 93 94 printf("LIBPTHREAD_VERSION: %s\n", pathbuf); 95 free(pathbuf); 96 97 if (sysconf(_SC_THREAD_PRIO_INHERIT) == -1) 98 printf("No Prio inheritance support\n"); 99 100 printf("Prio inheritance support present\n"); 101 102 return 0; 103} 104