title: pthread_setschedprio() fails with "EINVAL"
body: <p>I just started with pthreads and don't know much about it. I was trying to set the priorities of pthreads using  pthread_setschedprio() but it returns "EINVAL". Here is my code:</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  #include &lt;errno.h&gt;
  
  void *Run(void *ptr);
  
  class Thread {
  public:
      pthread_t myPthread;
  
      void start() {
          pthread_create( &amp;myPthread, NULL, Run, (void*)this );
      }
  
      Thread() { }
      virtual void run() = 0;
  };
  
  void *Run( void *ptr ) {
     Thread* tmp;
     tmp = (Thread*)ptr;
     tmp-&gt;run();
  }
  
  
  class MyThread : public Thread {
  public:
      virtual void run() {
          while (1) {
              printf("Running\n");
              sleep(1);
          }
      }
  };
  
  
  
  
  MyThread t1;
  
  
  int main()
  {
      int status;
  
      t1.start();
      status= pthread_setschedprio(t1.myPthread, 300);
      if(status!=0)
      {
          if(status==EPERM)
          {
              fprintf(stderr,"EPERM\n");
          }
          else if(status==EINVAL)
          {
              fprintf(stderr,"EINVAL\n");
          }
          else
          {
              fprintf(stderr,"neither EPERM nor EINVAL\n");
          }
  
          fprintf(stderr,"error %d\n",status);
  
          errno=status;
  
          perror("");
  
          exit(1);
      }
     pthread_join( t1.myPthread, NULL);
  
      exit(0);
  }
  </code></pre>
  
  <p>When I try to compile it, I get 
  EINVAL
  Running
  error 22
  Invalid argument</p>
  
  <p>Can anybody tell me why I get the error and how I can solve it?</p>