Results 1 to 3 of 3
(Updated...)
I'm trying to simply raise the priority of one thread.
My program has two threads:
1. a thread to capture from a UDP socket and write to the shared ...
- 03-24-2009 #1Just Joined!
- Join Date
- Mar 2009
- Location
- San Diego, CA
- Posts
- 2
Changing a pthread to a high priority
(Updated...)
I'm trying to simply raise the priority of one thread.
My program has two threads:
1. a thread to capture from a UDP socket and write to the shared buffer
2. a thread to read from the shared buffer, parse the data and write to disk.
I'm using pthreads (POSIX threads).
All I want to do now is raise the priority of thread #1 as high as possible so it is unlikely (ideally impossible) for it to miss UDP packets.
To attempt to change thread priority I do:
pthread_setschedparam(pthread_udp_capture_process // Target thread
policy, // == 0. Same as thread had initially.
&sparam);
If I set sparam.schedpriority to anything other than 0 (the value schedpriority had when the thread was created), pthread_setschedparam returns the error: Invalid Argument.
I've tried sudo on my program. Still can't change the thread priority.
Does nice do it? Other recommended API?
Any ideas?
- 05-01-2009 #2Just Joined!
- Join Date
- May 2009
- Posts
- 1
hi
We had a similar problem to urs...
By default the sched policy is sched_other, and this has a static priority of 0.
so i tried changing the policy to sched_rr, and sched_fifo, in these u can set the priority to a higher value.... but not to a value <0.
So, what we did was that we ran our process on a lesser priority value. For eg is process name is abc, we ran
./nice -n 2 abc
This shall run the process abc in the priority of 2.
Now inside the thread (in which u want to raise the priority, the udp thread), set teh scheduling policy to Sched_rr and set its priority to 0.
This ways u can increase the priority level.
- 07-26-2011 #3Just Joined!
- Join Date
- Jul 2011
- Posts
- 2
you can raise the priority by running as root or check capabilities property of the system (CAPS_SYS_NICE).


