Steve Papacharalambous wrote:
>
> "Santhosh Kumar M [CEC-S]" wrote:
> >
> > Hi,
> >
> > Is there a way to change the priority of a thread which is
> > running. Is there any interface to change the attributes of an task
> > dynamically.
> >
> > Santhosh
> >
> > --- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> > ----
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/~rtlinux/
>
> Hi Santosh,
>
> One way of changing the priority of a running thread is to use the
> pthread_getschedparam and pthread_setschedparam calls. The following
> code segment could be used to change the priority of a running thread:
>
>
>-----------------------------------------------------------------------------------------
>
> pthread_t self;
> int my_policy;
> struct sched_param my_param;
>
> self = pthread_self();
>
> // Get the current thread scheduling parameters.
> if(( r_c = pthread_getschedparam(self, &my_policy, &my_param)) != 0) {
> rt_printk("pthread_getschedparam error: %d\n", r_c);
> }
>
> // Set thread priority to the new value.
> my_param.sched_priority = NEW_PRIORITY;
> if(( r_c = pthread_setschedparam(self, my_policy, &my_param)) != 0) {
> rt_printk("pthread_setschedparam error: %d\n", r_c);
> }
>
>
NOTE: When you do this the results may not be what you would expect.
This can
raise or lower the priority but it will not prempt a lower priority
thread. In
other words. You set a thread to higher priority and it is waiting on
data to
be supplied by an interrupt. When the interrupt comes in the thread
will be made
ready and will execute before lower priority threads but it must wait
for the
currently running, possibly lower priority, thread to suspend.
David Miller
-----------------------------------------------------------------------------------------
>
> There are interface calls to change other thread attributes, but these
> depend on which attribute that you want to change,
>
> Best regards,
>
> Steve
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> ---
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/~rtlinux/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/