[Asterisk-Dev] Re: Asterisk-Dev Digest, Vol 5, Issue 44

Angel Diaz adiaz at sinergis.com
Wed Dec 15 11:47:17 MST 2004


Yes, of course it help with that kind of explanation; Thanks !

About your question:

> Are you asking about a specific line in the * source code?
On the line 50 of  "cdr_addon_mysql.c" (Asterisk-addons).

I want to create another group of CDRs. The thing at this time is that,
after finished a call it is geerated a CDR and the information on this CDR
are the last app and the last context used.

My idea is to create CDRs containing the time durations on each Context the
call is using during the complete call. Then, create one CDR when the call
pass through each context and have the time it stay on each one.

Angel.

> Date: Wed, 15 Dec 2004 09:20:45 -0800
> From: TC <trclark at shaw.ca>
> Subject: Re: [Asterisk-Dev] MUTEX definition
> To: asterisk at vanderdecken.com, Asterisk Developers Mailing List
> <asterisk-dev at lists.digium.com>
> Message-ID: <00eb01c4e2ca$6aa86af0$c901a8c0 at w2ktopcat>
> Content-Type: text/plain; charset=iso-8859-1
>
> Dam that was good, I just read it to my 9 year old son & he gets it :)
> > Mutex mean mutual exclusion.
> >
> > It is a point in the code where access to Resources ( memory, code, or
> > data structures ) are given exclusive access. On a limited number of
> > threads can access that point in the code or the memory protected by the
> > code.
> >
> > Example.
> >
> > You and your wife own one car and only one key for your car, but each of
> > you wants to drive the car.
> >
> > The car key is the MUTEX. In order to drive the car you must have the
> > key.
> >
> > A MUTEX makes the code/thread wait until it can get the car key before
> > can continue.
> >
> > The code/thread you are running is waiting to cross a MUTEX is blocked
> > from running until your wife returns the car key to the key peg in the
> > house, then you can pick up the car key and do your thread errands.
> >
> > If your wife wants to use the car she is then "blocked" until you return
> > with the car key and put it back on the peg.
> >
> > Others maybe waiting for the car key, your children or parents, and they
> > could be ahead of you in the line. You must wait for the other "threads"
> > to get their turn before you can have the car key.
> >
> > Deadlocks can occur with MUTEX's if you are not careful.
> >
> > Lets say you also have a trailer and you want to use both the car and
> > the trailer at the same time. So you wait to get the car key and then
> > wait to get the trailer. When you have both you can go on vacation.
> >
> > But what if someone else wants the car and the trailer but they ask for
> > the trailer first and then they try to get the car key. Meanwhile you
> > have the car key and want the trailer.
> >
> > Now, because of the order of events and because threads can be
> > interrupted at anytime except in an Atomic function (further reading
> > involved, but an Atomic function can't be switched out off of the
> > CPU...) you have the key but your brother in law has the trailer. You
> > can't get the trailer until he lets go and he can't have the car until
> > you let go of the car key. This is deadly embrace, neither can continue
> > and the threads lock up.
> >
> > It is important to ask for resource in the correct order. That way
> > whomever gets the car key first can have the trailer if they want it.
> > But the thread/person that needs both must ask for the car key first and
> > then is allowed to ask for the trailer.
> >
> > Does this help?
> >
> > Are you asking about a specific line in the * source code?
> >
> > Race "The Tyrant" Vanderdecken
> > "In the Land of the Blind the One-eyed man is Elvis"
> >





More information about the asterisk-dev mailing list