Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: werme@alingo.zk3.dec.com (Eric Werme)
Subject: Re: Alpha UNIX Shared Memory - Need Ideas
Date: 1996/04/24	[thread overview]
Message-ID: <werme.830381784@alingo.zk3.dec.com> (raw)
In-Reply-To: 4ledut$nql@news1.h1.usa.pipeline.com

rsurwilo@usa.pipeline.com(Richard A. Surwilo) writes:

>However, the application does make heavy use of shared memory with multiple
>processes requiring access to shared resources. The biggest potential snag
>would seem to be coming up with an efficient method of shared memory
>locking under UNIX.

I believe the following acquire locks in a few instructions, as long as
the locks are available.

173% man pthread_mutex_lock 

pthread_mutex_lock(3)                                   pthread_mutex_lock(3)

NAME

  pthread_mutex_lock - Locks an unlocked mutex. If the mutex is already
  locked, the calling thread blocks until the mutex becomes available.

LIBRARY

  DECthreads POSIX 1003.1c Library (libpthread.so)

SYNOPSIS

  #include <pthread.h>

  int   pthread_mutex_lock(
                         pthread_mutex_t   *mutex);

STANDARDS

  Interfaces documented on this reference page conform to industry standards
  as follows:

  IEEE Std 1003.1c-1995, POSIX System Application Program Interface

PARAMETERS

  mutex     Mutex to be locked.

DESCRIPTION

  This routine locks a mutex with varying behavior as follows:

    +  If a recursive mutex was specified, the current owner of a mutex can
       relock the same mutex without blocking.  The lock count is incremented
       for each recursive lock within the thread.

    +  If an error-check mutex was specified and the current owner tries to
       lock the mutex a second time, the EDEADLK error is reported.  If the
       mutex is locked by another thread, the calling thread waits for the
       mutex to become available.

    +  If a normal mutex is specified, a deadlock can result if the current
       owner of a mutex calls this routine in an attempt to lock the mutex a
       second time. (The deadlock is not detected or reported.)

  See pthread_mutexattr_settype_np for information about normal, recursive,
  and  error-check mutexes.

  The thread that has locked a mutex becomes its current owner and  remains
  the owner until the same thread has  unlocked it. This routine returns with
  the mutex in the locked state and with the current thread as the mutex's
  current owner.

RETURN VALUES

  If an error condition occurs, this routine returns an integer value indi-
  cating the type of error.  Possible return values are as follows:

  0         Successful completion.

  [EINVAL]  The value specified for mutex is invalid, or
            The mutex was created with the protocol attribute set to
            PTHREAD_PRIO_PROTECT and the calling thread's priority set higher
            than the mutex's current priority ceiling.)

  [EDEADLK] A deadlock condition is detected.

ERRORS

  None

RELATED INFORMATION

  Functions: pthread_mutexattr_settype_np(3), pthread_mutex_destroy(3),
  pthread_mutex_init(3), pthread_mutex_lock(3), pthread_mutex_trylock(3),
  pthread_mutex_unlock(3)

  Manuals: Guide to DECthreads and Programmer's Guide

174% man tis_mutex_lock

tis_mutex_lock(3)                                           tis_mutex_lock(3)

NAME

  tis_mutex_lock - Locks an unlocked mutex.

LIBRARY

  Standard C Library (libc.so, libc.a)

SYNOPSIS

  #include <tis.h>

  int   tis_mutex_lock(
                         pthread_mutex_t   *mutex);

STANDARDS

  None

PARAMETERS

  mutex     Mutex to be locked.

DESCRIPTION

  The tis_mutex_lock() function locks a mutex. A deadlock can result if the
  current owner of a mutex calls this routine in an attempt to lock the mutex
  a second time. (The deadlock is not detected or reported.)

  The thread that has locked a mutex becomes its current owner and  remains
  the owner until the same thread has  unlocked it. This routine returns with
  the mutex in the locked state and with the current thread as the mutex's
  current owner.

RETURN VALUES

  If an error condition occurs, this routine returns an integer value indi-
  cating the type of error.  Possible return values are as follows:

  0         Successful completion.

  [EINVAL]  The value specified for mutex is invalid.

  [EDEADLK] A deadlock condition is detected.

ERRORS

  None

RELATED INFORMATION

  Functions: tis_mutex_destroy(3), tis_mutex_init(3), tis_mutex_lock(3),
  tis_mutex_trylock(3), tis_mutex_unlock(3)

  Manuals: Guide to DECthreads and Programmer's Guide
-- 
Eric (Ric) Werme         |  werme@zk3.dec.com
Digital Equipment Corp.  |  This space intentionally left blank.



  parent reply	other threads:[~1996-04-24  4:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-21  4:00 Alpha UNIX Shared Memory - Need Ideas Richard A. Surwilo
1996-04-23  4:00 ` David Mosberger-Tang
1996-04-24  4:00 ` Eric Werme [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-04-20  4:00 Richard A. Surwilo
1996-04-23  4:00 ` Dirk Grunwald
1996-04-23  4:00 ` Peter Mayne
1996-04-24  4:00   ` Curt Smith
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox