strange problems with pthreads

From: Chris Friesen (cfriesen_at_ca.nortel.com)
Date: 02/20/04


Date: Fri, 20 Feb 2004 12:36:57 -0500

I'm running the following code as root, on a uniprocessor system. I get
an error printed out:

error:No such process priority:40 policy:2

Any idea what's going on? Am I doing something invalid?

Chris

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>

pthread_t t1;

void *func(void *p)
{
   pid_t pid;
   int status;

   struct sched_param schedParam;
   int policy = SCHED_RR;
   int priority = 40;

   schedParam.sched_priority = priority;

  int schedRc = pthread_setschedparam(t1, policy, &schedParam);
   if (schedRc != 0)
     {
       fprintf(stderr, "error:%s priority:%d policy:%d\n",
              strerror(schedRc), priority, policy);
     }

   pthread_exit(EXIT_SUCCESS);
   return 0;
}

int main(int argc, char **argv)
{
   pthread_create(&t1, 0, func,(void*)1);
   pthread_join(t1,0);
   return 0;
}

-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com


Relevant Pages

  • prog for electronis lessons.
    ... int vars_count; ... return res; ... int comparator(const void *p1, const void *p2) ... int print_tree(NODE *root) ...
    (Debian-User)
  • Graphs and identifying adjacent nodes
    ... I have an applet which has a graph that has a central node (root) from ... int from; ...
    (comp.lang.java.programmer)
  • Re: [PATCH 1/3] ftrace: add function tracing to single thread
    ... I think the end result was, if this file can only be changed by root, then ... One thing this doesn't deal with is pid wraparound. ... 'struct pid' for a particular task by doing a find_get_pid. ... context of the current task's pid namespace, which is what you want, I ...
    (Linux-Kernel)
  • Re: exiting chroot()
    ... > Only root can ptrace another process. ... ## Args: ebx -> status ... # ptrace_attach (pid) failed ...
    (comp.unix.programmer)
  • Re: correct tree
    ... return type from void to int. ... The author had main's return as void. ... void insert(node ** tree, node * item) ... you will see the corresponding argument is &root. ...
    (comp.lang.c)