Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with threads

Status
Not open for further replies.

steubi

Programmer
Sep 14, 2004
5
CA
Hi,

I am trying to create two threads using the pthread library.
Both threads have the same attributes and do the same thing (they are both listening to UDP port and waiting for messages).
The issue here is that one of the thread (the one created last) is a lot slower than the other. (when I send a message to the second thread it takes longer to process it than when I send it to the first one created).

Here are the attributes I use for the threads:
Code:
pthread_attr_init(&custom_attributes);
pthread_attr_setscope(&custom_attributes, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setinheritsched(&custom_attributes, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&custom_attributes, SCHED_RR);
rr_param.sched_priority = sched_get_priority_max(SCHED_RR);
pthread_attr_setschedparam(&custom_attributes,&rr_param);

Any idea of what I may do wrong?

Thanks

 
> Any idea of what I may do wrong?
If you send a message to thread 2, then immediately send a message to thread 1, is it equally unresponsive?

--
 
No,
What I have done is send messages to thread 1 and 2 in turn (the message rate being really slow). Thread 1 is always faster than thread 2. But sometimes both of them become even slower.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top