public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Grant Edwards <grante@visi.com>
To: Sergei Organov <osv@javad.ru>
Cc: bartv@redhat.com, ecos-discuss@sourceware.cygnus.com
Subject: Re: [ECOS] No binary semaphore in C API?
Date: Wed, 28 Mar 2001 11:05:00 -0000	[thread overview]
Message-ID: <20010328130507.A2999@visi.com> (raw)
In-Reply-To: <871yrhixi0.fsf@osv.javad.ru>

On Wed, Mar 28, 2001 at 10:01:11PM +0400, Sergei Organov wrote:

> Yes, I see, but attempt was made to make general decisions
> about semantics of binary semaphore based on its incorrect use.

What incorrect use is that?

> Every primitive could be used incorrectly, -- this doesn't mean
> its semantics is unclear.
> 
> > You describe a different use for binary semaphores where the
> > assertion would be incorrect.
> 
> Yes, and I think that unlike initial poster I described correct
> use for binary semaphore.

Are you saying that using semaphores for mutual exlcusion is
an "incorrect" usage?  According the OS text we used (many
years ago), mutual exclusions was one ot standard uses for
semaphores. 

> > Hence there is confusion about semantics, which is pretty
> > disastrous for a synchronization primitive.
> 
> The key word here is "synchronization", I think. Using
> synchronization primitive for mutual exclusion is a mistake no
> matter which synchronization primitive is used.

Your usage of "mutal exclusion" vs. "synchronization" is new to
me. I was taught that mutual exclusion is one type of
synchronization.  What's your definition of "synchronization"?

> This has nothing to do with semantics of binary semaphore, I'm
> afraid. For example, the same way I can try to prove that mutex
> has confusing semantics: "I've tried to use it for task
> synchronization but that didn't work as expected" ;-) Didn't
> you hear about guys that try to lock mutex from one thread and
> then unlock it from another? I heard it many times, but nobody
> wants to remove mutexes or change their semantics because of
> this.
> 
> I believe that once semantics is documented, there should be no
> confusion about it. And the only semantics that seems to be
> reasonable for binary semaphore is the current one.

I also think that once you decide what to do about post() on a
true-valued semaphore, the semantics for a binary semphore are
not ambiguous or confusing at all.  Either a second post() is a
noop, or it's not allowed.

> > Arguably the better alternative would be to implement a new
> > mutex class which deals with thread groups, rather than
> > overloading binary semaphores.

I don't see how this is "overloading" a binary semaphore.  I
thought that mutual exclusion was one of the primary uses for
which binary semaphores were intended.

> > The latter could then be left with their existing semantics,
> > although people might still be confused and use them
> > incorrectly for mutual exclusion.

Again, why is it incorrect to use a binary semaphor for mutual
exclusion?  FWIW, that's how I was taught to do mutual
exclusion.  Way back when, all we had were semaphores (binary
or counting), and we got along just fine. ;) Both of the RTOS
kernels I designed had nothing other than binary semaphores for
mutual exclusion, and everybody seemed happy.

-- 
Grant Edwards
grante@visi.com

  reply	other threads:[~2001-03-28 11:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-16 12:01 Grant Edwards
2001-03-19 13:42 ` Jonathan Larmour
2001-03-26  3:53   ` Nick Garnett
2001-03-26  7:12     ` Fabrice Gautier
2001-03-26 11:37     ` Grant Edwards
2001-03-27  2:00       ` Nick Garnett
2001-03-27  5:32         ` Grant Edwards
2001-03-28  5:29         ` Bart Veer
2001-03-28  6:45           ` Sergei Organov
2001-03-28  7:38             ` Grant Edwards
2001-03-28  7:39             ` Bart Veer
2001-03-28 10:01               ` Jonathan Larmour
2001-03-28 10:01               ` Sergei Organov
2001-03-28 11:05                 ` Grant Edwards [this message]
2001-03-29 11:51                   ` Sergei Organov
2001-03-29 11:49                     ` Grant Edwards
2001-03-29 11:55           ` Chris Gray
2001-03-29 19:33             ` Bart Veer
2001-03-29 20:50               ` Grant Edwards
2001-03-30  2:22               ` Sergei Organov
2001-03-30  6:54                 ` Grant Edwards
2001-03-30  7:42                   ` Sergei Organov
2001-03-30  5:39 Rosimildo daSilva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010328130507.A2999@visi.com \
    --to=grante@visi.com \
    --cc=bartv@redhat.com \
    --cc=ecos-discuss@sourceware.cygnus.com \
    --cc=osv@javad.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).