Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Sep 2000 11:08:12 +0930
From:      Greg Lehey <grog@lemis.com>
To:        Mohan Krishna P <penumetcha@yahoo.com>
Cc:        freebsd-hackers@FreeBSD.ORG, arch@wantadilla.lemis.com
Subject:   Re: semaphores inside kernel???
Message-ID:  <20000922110812.J66887@wantadilla.lemis.com>
In-Reply-To: <20000919035519.24195.qmail@web115.yahoomail.com>; from penumetcha@yahoo.com on Mon, Sep 18, 2000 at 08:55:19PM -0700
References:  <20000919035519.24195.qmail@web115.yahoomail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[Format recovered--see http://www.lemis.com/email/email-format.html]

On Monday, 18 September 2000 at 20:55:19 -0700, Mohan Krishna P wrote:
> hi,

It would make things a *lot* easier to read if you made your lines all
the same length.  I've fixed it here.

> i am implementing a pseudo-devicer, many instaces of this device may
> be active, all have to share a resource. all instances have to
> synchronize their access to the resource. trying to implement this,
> i ended up with a less powerful version of semaphores. since the
> resultant code became little complex, i want to replace that with
> the more generic semaphores.
>
> i checked the include files, but i couldn't find any semaphore
> functions(semget,semctl,semop) which are specific or meant for use
> inside kernel.  does it mean they aren't available inside kernel??
> if i am wrong, can someone suggest me how to use them??

You're probably thinking about System V user-accessible semaphores.
This particular semaphore implementation is complicated and slow, and
the implementation is flawed.  You don't want them in the kernel, and
yes, they're not available at the moment, though you could probably do
it.

> does it mean they aren't available inside kernel?? if i am wrong,
> can someone suggest me how to use them??

Well, the real question is, what exactly do you want to use them for?
As John Baldwin says, we now have mutexes, though they won't show in a
-RELEASE version for quite some time.  We're still discussing the
evolution of locking primitives, but at the moment it looks like we
can distinguish between semaphores and "mutexes" in the following way:

- A "mutex" (in quotes because "mutex" is also a generic term; this is
  more like a simple lock) is used for short term serialization when
  accessing critical data or code.  Only one process can take the
  mutex at a time.

- A semaphore may be held for longer periods of time.  Multiple
  processes (for small values of "multiple") can take the semaphore at
  the same time.  This means that, unlike mutexes, semaphores don't
  have "owners", and the process which "releases" the semaphore may
  not be the one that took it.

Which better describes your usage?

Greg
--
When replying to this message, please take care not to mutilate the
original text.  
For more information, see http://www.lemis.com/email.html
Finger grog@lemis.com for PGP public key
See complete headers for address and phone numbers


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000922110812.J66887>