RES: Thread Scheduler Priority

2014-05-30 Thread Fred Pedrisa
Hello,

This is 'min' and 'max' for the default policy :

Min : 0, Max : 103

In my system.

-Mensagem original-
De: owner-freebsd-curr...@freebsd.org
[mailto:owner-freebsd-curr...@freebsd.org] Em nome de Ian Lepore
Enviada em: sexta-feira, 30 de maio de 2014 23:50
Para: Fred Pedrisa
Cc: 'freebsd-current'
Assunto: Re: Thread Scheduler Priority

On Thu, 2014-05-29 at 02:12 -0300, Fred Pedrisa wrote:
> Hi, Guys.
> 
>  
> 
> How can I adjust a certain thread to have the maximum system priority 
> in the scheduler ?
> 
>  
> 
> I've tried doing it this way :
> 
>  
> 
>/* Set thread priority. 
> */
> 
>if 
> (pthread_getschedparam(ts[gnThreadID], &police, ¶m[gnThreadID]) != 
> 0)
> 
>{
> 
>error 
> ("Unable to get priority");
> 
>return 
> 1;
> 
>}
> 
>  
> param[gnThreadID].sched_priority = 99;
> 
>if 
> (pthread_setschedparam(ts[gnThreadID], police, ¶m[gnThreadID]) != 
> 0)
> 
>{
> 
> error("Unable to set priority");
> 
> return 1;
> 
>}
> 
>  
> 
> However, in 'top', I don't see the process threads switching to -92 
> priority, like other threads in the system, is something I did wrong 
> or maybe I might be missing something ?

You can't just set the priority to any number you want... per the man page
for pthread_setschedparam() the value has to fall within the ranges returned
by sched_get_priority_min() and sched_get_priority_max() for the given
scheduling class.  On freebsd those ranges are 0-31.

I suspect from your statement of wanting "maximum system priority" maybe
what you need to do is change the scheduling class from SCHED_OTHER to
SCHED_RR, that should give you realtime priority.  Be aware that a realtime
thread that is compute-bound will take over the system (or one core on an
SMP system); it will get all cycles if it is always runnable.

If what you're looking for is the thread equivelent of using the nice
command, so that you give a boost to a thread over other threads in the
timeshare (SCHED_OTHER) scheduling class, there is currently no way to do
that in freebsd.

Last year for $work I about went crazy trying to figure out the mapping
between pthread scheduling classes and priorities and freebsd's idea of
thread prorities.  I eventually gave up on the pthread API and used the
freebsd native function rtprio_thread() instead.

-- Ian


___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


RES: Thread Scheduler Priority

2014-05-30 Thread Fred Pedrisa
Any clue on this ? :(

-Mensagem original-
De: owner-freebsd-curr...@freebsd.org
[mailto:owner-freebsd-curr...@freebsd.org] Em nome de Fred Pedrisa
Enviada em: quinta-feira, 29 de maio de 2014 02:19
Para: 'Adrian Chadd'
Cc: 'freebsd-current'
Assunto: RES: Thread Scheduler Priority

Hello,

Yes.

-Mensagem original-
De: owner-freebsd-curr...@freebsd.org
[mailto:owner-freebsd-curr...@freebsd.org] Em nome de Adrian Chadd Enviada
em: quinta-feira, 29 de maio de 2014 02:18
Para: Fred Pedrisa
Cc: freebsd-current
Assunto: Re: Thread Scheduler Priority

are you doing this all as root?


-a


On 28 May 2014 22:12, Fred Pedrisa  wrote:
> Hi, Guys.
>
>
>
> How can I adjust a certain thread to have the maximum system priority 
> in the scheduler ?
>
>
>
> I've tried doing it this way :
>
>
>
>/* Set thread priority. 
> */
>
>if 
> (pthread_getschedparam(ts[gnThreadID], &police, ¶m[gnThreadID]) !=
> 0)
>
>{
>
>error 
> ("Unable to get priority");
>
>return 
> 1;
>
>}
>
>
> param[gnThreadID].sched_priority = 99;
>
>if 
> (pthread_setschedparam(ts[gnThreadID], police, ¶m[gnThreadID]) !=
> 0)
>
>{
>
> error("Unable to set priority");
>
> return 1;
>
>}
>
>
>
> However, in 'top', I don't see the process threads switching to -92 
> priority, like other threads in the system, is something I did wrong 
> or maybe I might be missing something ?
>
> ___
> freebsd-current@freebsd.org mailing list 
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


RES: Thread Scheduler Priority

2014-05-28 Thread Fred Pedrisa
Hello,

Yes.

-Mensagem original-
De: owner-freebsd-curr...@freebsd.org
[mailto:owner-freebsd-curr...@freebsd.org] Em nome de Adrian Chadd
Enviada em: quinta-feira, 29 de maio de 2014 02:18
Para: Fred Pedrisa
Cc: freebsd-current
Assunto: Re: Thread Scheduler Priority

are you doing this all as root?


-a


On 28 May 2014 22:12, Fred Pedrisa  wrote:
> Hi, Guys.
>
>
>
> How can I adjust a certain thread to have the maximum system priority 
> in the scheduler ?
>
>
>
> I've tried doing it this way :
>
>
>
>/* Set thread priority. 
> */
>
>if 
> (pthread_getschedparam(ts[gnThreadID], &police, ¶m[gnThreadID]) != 
> 0)
>
>{
>
>error 
> ("Unable to get priority");
>
>return 
> 1;
>
>}
>
>
> param[gnThreadID].sched_priority = 99;
>
>if 
> (pthread_setschedparam(ts[gnThreadID], police, ¶m[gnThreadID]) != 
> 0)
>
>{
>
> error("Unable to set priority");
>
> return 1;
>
>}
>
>
>
> However, in 'top', I don't see the process threads switching to -92 
> priority, like other threads in the system, is something I did wrong 
> or maybe I might be missing something ?
>
> ___
> freebsd-current@freebsd.org mailing list 
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"