On 6/27/06, Tzahi Fadida <[EMAIL PROTECTED]> wrote:
On Tuesday 27 June 2006 20:58, you wrote:
> On 27/06/2006, at 15:03, Tzahi Fadida wrote:
> > I am looking for an answer on python threads lock behaviour.
> > So far, i have not managed to get an answer on #python,
> > whatsup,#twisted,google...
>
> You probably need to revise your questions.
Would like to say why?
What do you mean by "threads lock behaviour"? It is unclear!
>
> > If i have many threads running and there is a resource all want
> > to posses using a lock, i.e., lock.acquire().
> > one obviously is going to posses the lock.
> > My question is, when it is released using lock.release() which of
> > the threads
> > is going to acquire the lock? is it a random process or
> > a FIFO order. I am trying to understand if starvation is possible
> > in this particular instance.
>
> I think its undefined.
>
> > My other question, is what is more efficient:
> > using locks, conditions, events, queues. i.e. i am building
> > a server and i want to avoid unneccessary polling operations.
>
> The question is too general to get any useful answer.
Sorry, but i don't think you are correct.
I think he is. "unnecessary polling operations" have nothing to do with locks,
events, conditions and queues. You can implement busy waiting using
all those :-).
Also the fact that you did not get the answer says something, don't
you think so?
For example, Event uses
notifyAll while Condition uses notify etc... there is a difference, however
there are other considerations like robustness etc...
What do you mean "robustness and etc..."? I hope you will find some information
here: http://www.boost.org/doc/html/threads/faq.html. See 8 and 11.
I am looking for an answer from someone who have experience
with these.
>
> Basically, avoid threads if you can - its hard to program and even
> harder to test. It also does not scale well with Python because of
> the GIL, unlike C, most of the time all your threads share the same CPU.
Basically what you are saying, python is a lame language since you cannot
use threads with it.
He did not said that.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/