Subject: Re: change thread priorities
To: Paul Winder <Paul.Winder@tadpole.com>
From: Rui Paulo <rpaulo@fnop.net>
List: tech-kern
Date: 05/18/2006 14:13:33
On 2006.05.18 11:20:35 +0100, Paul Winder wrote:
> I have a multithreaded application and I want to have some of the 
> threads run at different priorities. I try:
> 
> 	pthread_attr_init(&attr);
> 	pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
> 	param.sched_priority = 10;
> 	pthread_attr_setschedparam(&attr, &param);
> 
> The pthread_attr_setschedparam() call always returns EINVAL unless I set 
> sched_priority to 0!
> 
> I also tried adding a call to:
> 	pthread_attr_setschedpolicy(&attr, SCHED_RR);
> 
> before pthread_attr_setschedparam(), but thats gets ENOTSUP.
> 
> I'm running current.
> 
> Does NetBSD support this?

I don't think so.

int     
pthread_attr_setschedparam(pthread_attr_t *attr,
    const struct sched_param *param)
{       
  
        if (param == NULL)
                return EINVAL;
                
        if (param->sched_priority != 0)
                return EINVAL;
        
        return 0;
}       

[...]

int
pthread_attr_setschedpolicy(pthread_attr_t *attr,
    int policy) 
{               
        
        if (policy != SCHED_OTHER) 
                return ENOTSUP;
 
        return 0;
}


We should probably have a document to describe what's missing.

	-- Rui Paulo