[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Threading problem at run time - had to use pthread_yield



Hi,

I had to migrate my code from 7.2 Redhat Linux to 9.0 Redhat (Kernel
2.4.20) and faced some problem, while execution. ie. Some of the threads
will never get the processing time.

My process is network based and has many sockets. On the arrival of data
from a socket, I create a thread passing the socket ID as arguement to the
initial function.

I also have some mutex locking (pthread_mutex_lock), when we send some data
or get some data from these sockets. Always the mutex is held by only one
thread.

If I set the environment variable LD_ASSUME_KERNEL=2.4.18, it starts
working properly.

I had to use pthread_yield after every unlock to come out of this. But this
gives other performance problems.

I tested the following code also,

pthread_mutex_t globalMutex;


void sampleThread1()
{
  lock the globalMutex
  sleep for 1 second
  unlock the globalMutex
}

void sampleThread2()
{
  lock the globalMutex
  sleep for 1 second
  unlock the globalMutex
}

int main()
{
  create the thread (sampleThread1)
  sleep for some time
  create the thread (sampleThread2)
}

In the above case only the sampleThread1() will be running in RH9.0, where
as in RH7.3, it switches between the threads.

Is there any was I can get the behavior as in RH7.3 and any reason as to
why this is happening. Also the process should work as a user process (not
with SU privilage) and cannot set the Scheduling etc.


Thanks in advance,
Prasad
  


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]