From owner-freebsd-current Sat Nov 24 16:47:10 2001 Delivered-To: freebsd-current@freebsd.org Received: from web21109.mail.yahoo.com (web21109.mail.yahoo.com [216.136.227.111]) by hub.freebsd.org (Postfix) with SMTP id B038F37B405 for ; Sat, 24 Nov 2001 16:47:05 -0800 (PST) Message-ID: <20011125004705.22380.qmail@web21109.mail.yahoo.com> Received: from [62.254.0.4] by web21109.mail.yahoo.com via HTTP; Sat, 24 Nov 2001 16:47:05 PST Date: Sat, 24 Nov 2001 16:47:05 -0800 (PST) From: Hiten Pandya Subject: Re: some info (new) To: Maxime Henrion Cc: current@freebsd.org In-Reply-To: <20011125014200.A831@nebula.noos.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hi maxime... thanks very very much.. now i get it..., its like.. a mutex is a lock, which is used when things are done in parralel and to avoid corruption of the data which is being processed... i took an example of the way i used to lock files in PERL, in order to avoid multiple writes at the same time... one more question... if there is a lock order reversal.. is there a way that can be solved.. for e.g. by using on of the MTX_XX things... thanks... regards... Hiten Pandya --- Maxime Henrion wrote: > Hiten Pandya wrote: > > hi all, > > sorry for running -current.. but i am an > enthusiastic > > and challenging man...(boy)... > > > > anyways.. whats a mutex and a lock order > reversal... > > if you could point to some good manual on these > > subjects... thanks... > > > > help is appreciated... > > > > thanks again... > > A mutex is an algorithmic object used to serialize > operations. It > stands for ``mutual exclusion''. It's useful when > the same code is ran > several times in parallel. For example, if two > threads wanted to modify > a linked list in the same time, there is a chance > that the linked list > would get corrupted since an insert or remove > operation is not atomic > (one of the thread could get preempted when it has > not finished to > remove or insert an element, and thus the linked > list is not in a normal > state). > > In such cases, every part of the code that modify > the linked list has to > obtain the mutex before doing it and release after. > If another thread > tries to acquire the mutex, it will block until the > first thread has > released it. > > When some code has to obtain two locks or more, > deadlocks might happen. > If thread 1 has lock A and tries to acquire lock B > while thread 2 has > lock B and wants lock A, then both threads will > block indefinitely. To > solve this, one way is to always obtain the lock in > the same order. The > warning messages you got show that some code is > violating this lock > order somewhere. > > I found ``Unix Internals'' from Uresh Vahalia to be > a very good book on > this topic. > > Hope this helps, > Maxime Henrion > -- > Don't be fooled by cheap finnish imitations ; BSD is > the One True Code ===== regards, Hiten Pandya MOTD: I just like _pumping_ the daylights out of a PENGUIN!!! __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message