[ntp:questions] new driver development
Richard B. Gilbert
rgilbert88 at comcast.net
Sun Apr 10 21:22:51 UTC 2011
On 4/9/2011 7:51 PM, Hal Murray wrote:
> In article<4DA0C50F.3050505 at comcast.net>,
> "Richard B. Gilbert"<rgilbert88 at comcast.net> writes:
>> On 4/9/2011 12:55 PM, Hal Murray wrote:
>>> Is there any way to test to see if a mutex has been initialized?
>> You initialize your mutex BEFORE it is needed.
> Right. But consider the case of ntpd and gpsd.
> Who initializes it? Even if you say "You must start X before Y"
> (which looks pretty ugly to me) you need something to cover the
> case where you start X, it initializes the mutex, you start Y,
> and now you want to restart X. This time, it can't initialize
> the mutex because Y may be using it.
It looks to me as if, in the case you describe, the mutex must know who
"owns" it. When you start, you must test for the existence of the
mutex. If it does not exist, you must create and initialize it. If it
does exist and belongs to you, you must either use the resource and
release the mutex, or release the mutex without using the resource. If
the mutex exists and DOES NOT belong to you then there are two cases;
you need it or not. If you need it you queue up to gain the mutex. If
you don't need it, you need not do anything.
More information about the questions