1 /* 2 * Copyright (c) 2004, Intel Corporation. All rights reserved. 3 * This file is licensed under the GPL license. For the full content 4 * of this license, see the COPYING file at the top level of this 5 * source tree. 6 * adam.li (at) intel.com 7 * 8 * The pthread_getschedparam() function shall retrieve the scheduling 9 * policy and scheduling parameters for the thread whose thread ID is 10 * given by thread and shall store those values in 11 * policy and param, respectively. The priority value returned from 12 * pthread_getschedparam() shall be 13 * the value specified by the most recent pthread_setschedparam(), 14 * pthread_setschedprio(), or pthread_create() call affecting the 15 * target thread. It shall not reflect any temporary adjustments to 16 * its priority as a result of any priority inheritance or ceiling functions. 17 * 18 */ 19 20 #include <pthread.h> 21 #include <stdio.h> 22 #include <string.h> 23 #include <stdlib.h> 24 #include "posixtest.h" 25 26 #define ERR_MSG(f, rc) printf("Failed: func: %s rc: %s (%u)\n", \ 27 f, strerror(rc), rc) 28 29 static void *thread_func() 30 { 31 struct sched_param sparam; 32 int policy; 33 int rc; 34 35 rc = pthread_getschedparam(pthread_self(), &policy, &sparam); 36 if (rc != 0) { 37 ERR_MSG("pthread_getschedparam()", rc); 38 exit(PTS_FAIL); 39 } 40 return NULL; 41 } 42 43 int main(void) 44 { 45 pthread_t new_th; 46 int rc; 47 48 rc = pthread_create(&new_th, NULL, thread_func, NULL); 49 if (rc) { 50 ERR_MSG("pthread_create()", rc); 51 return PTS_UNRESOLVED; 52 } 53 54 pthread_join(new_th, NULL); 55 printf("Test PASSED\n"); 56 return PTS_PASS; 57 } 58