This discussion is archived
5 Replies Latest reply: Aug 14, 2013 7:29 PM by ShuiXinZhang RSS

Why thr_setprio method will fail on Solaris 11?

ShuiXinZhang Newbie
Currently Being Moderated

Hi all,

I used the below test code to run on Solaris 11 and Solaris 10. But the method thr_setprio will fail with return code 1, which means "The caller does not have the appropriate permission to set the priority to the value specified."

It can work well on Solaris 10. I used the same executable file "test", which is compiled on Solaris 11 or Solaris 10.

 

Solaris 11 platform information.

bash-4.1$ CC -V

CC: Sun C++ 5.12 SunOS_sparc 2011/11/16

Oracle Corporation      SunOS 5.11      11.0    November 2011

 

The result in Solaris 11

bash-4.1$ ./test

******my set prio result: 1

Hello

Thread run over.

 

Solaris 10 platform information:

bash-3.00$ CC -V

CC: Sun C++ 5.8 2005/10/13

Sun Microsystems Inc.   SunOS 5.10      Generic January 2005

 

The result in Solaris 10.

bash-3.00$ ./test

******my set prio result: 0

Hello

Thread run over.

 

#include "thread.h"
#include "stdio.h"
static void * Hello(void* arg)
{
  printf("Hello\n");
  return 0;
}
static void mythread()
{
thread_t tid;
int ret;
int newprio = 20;
/* suspended thread creation */
ret = thr_create(NULL, NULL, Hello, NULL, THR_SUSPENDED, &tid);
/* set the new priority of suspended child thread */
ret = thr_setprio(tid, newprio);
printf("******my set prio result: %d\n", ret);
/* suspended child thread starts executing with new priority */
ret = thr_continue(tid);
ret = thr_join(tid, NULL, NULL);  
printf("Thread run over.\n");
}
void main(int argc, char **argv)
{
mythread();
}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points