Assume that the following code is being executed by 10 threads.
Pthread_mutex_lock (& Lock) Some trivial code pthread_mutex_unlock (& amp; lock)
For clarification purposes, you can say that Threads T1, T2, T3 ..... T10 is my requirement that till T1 or T2 or T3 (ie T1, T2 or T3 any) are waiting to get the lock The other threads should not be able to achieve T4, T5, T6 ..... T10 lock in relation ie T1, T2 and T3 to get lock in relation to other thread Urwata should.
I think this thread can be done by increasing the priority of T1, T2 and T3
Although this is a pseudo code
Thread T1 or T2 or T3 increases its priority pthread_mutex_lock (& Lock) Some trivial code pthread_mutex_unlock (& Lock) If this thread is T1 or T2 or T3 has the generality Priority Decrease Please note that I need a solution that works for Linux platform and uses pthreads Should. I really do not care about any other platform.
Also keep in mind that I really do not want to make these 3 threads in real time, except that they want to exclude their defualt behavior (scheduling and performance) priority , Which is in the small piece code above, I want them to always have a priority in getting the lock.
I have read some man pages about scheduling policies and scheduling priorities in scripts but in fact out: (
will this work? Will you have to do the above work? Can I help with the exact pthread API?
Regards to Redness
As I think, the only way you can truly guarantee it is to write a lock that works like a self
You will need the condition variable, and the number of wait for the low / high priority thread will be calculated.
In terms of the concepts and need of API, It is similar to applying a reading / lock lock (but that means none of you are totally different, obviously - but if you think how R / W lock is working, then you will understand how you You want to apply.)
You can see the implementation of the written lock:
In the lower priority thread, you will have to wait to finish high priority threads, in the same way to eliminate readers Wait for the author.
(The book from the above code is also taken from a great Pozzia threads book BTW)
Comments
Post a Comment