lkml.org 
[lkml]   [2009]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
On Sun, Jul 26, 2009 at 08:17:11AM -0000, Thomas Gleixner wrote:
> The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been
> done. Some of the users are real semaphores and we should name them as
> such instead of confusing everyone with "MUTEX".

> +#define DEFINE_SEMAPHORE(name) \
> + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
> +

> +static inline void semaphore_init(struct semanphore *sem)
> +{
> + sema_init(sem, 1);
> +}
> +
> +/*
> + * semaphore_init_locked() is mostly a sign for a mutex which is
> + * abused as completion.
> + */
> +static inline void __deprecated semaphore_init_locked(struct semanphore *sem)
> +{
> + sema_init(sem, 0);
> +}

The CS literature doesn't really know about a default value for counting
semaphores. I think you're better off converting init_MUTEX and
init_MUTEX_locked to explicit sema_init use than adding these and
introducing another semaphore_* namespace in addition to the sema_* we
already have. Adding a DEFINE_SEMAPHORE makes sense, but it should take
a second argument for it's initial value.



\
 
 \ /
  Last update: 2009-07-27 17:27    [W:0.876 / U:1.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site