On Tuesday 27 June 2006 22:26, you wrote:
> 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!

That's because there was no question until the second paragraph, sish...

>
> > > > 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?

No, it means that people does not know.
I know (thru google browsing) though that python threads use pthreads.
I asked because if python (or the underlying os or whatever goes on the lower
levels) does not take care of threads locks to not get threads starved, i will
have to take care of it myself using queues and conditions which i want to be
sure is really neccessary first.
Btw, a lock = Thread.allocate_lock()

>
> >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.

Did not help. I am asking about threads in python not what threads or mutex 
are.

>
> > 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.

It sure sounded like that.

-- 
Regards,
        Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS:  see at 
http://members.lycos.co.uk/my2nis/spamwarning.html

לענות