Re: [RFC] New locking primitive for 2.5

Denis Vlasenko
2002-02-08T08:27:26Z

On 7 February 2002 16:22, Christoph Hellwig wrote:
> In article <3C629F91.2869CB1F@dlr.de> you wrote:
> > The new lock uses a combination of a spinlock and a (mutex-)semaphore.
> > You can lock it for short-term issues in a spin-lock mode:
> >
> > combi_spin_lock(struct combilock *x)
> > combi_spin_unlock(struct combilock *x)
> >
> > and for longer lasting tasks in a sleeping mode by:
> >
> > combi_mutex_lock(struct combilock *x)
> > combi_mutex_unlock(struct combilock *x)
>
> I think this API is really ugly. If both pathes actually do the same,
> just with different defaults, one lock function with a flag would be
> much nicer. Also why do we need two unlock functions?
>
> What about the following instead:
>
> combi_lock(struct combilock *x, int spin);
> combi_unlock(struct combilock *x);

What is easier to read:
combi_lock(zzzt_clock, 1);
// go grepping .h to find out what this 1 means
or
combi_spin_lock(zzzt_clock);
?

OTOH single unlock() looks good.
--
vda