comp.lang.ada
 help / color / mirror / Atom feed
From: "DuckE" <nospam_steved@pacifier.com>
Subject: Re: Alsys Ada 83 to Green Hills Ada 95: ARTK Resource Manager
Date: 1999/10/29
Date: 1999-10-29T00:00:00+00:00	[thread overview]
Message-ID: <381a77ca.0@news.pacifier.com> (raw)
In-Reply-To: 1rUZOBNgrjUOCSMI4WnzEyyo2oMj@4ax.com

I believe what you're looking for is offered by Ada 95 protected types.

Here is a small example of a protected type that implements a mutual
exclusion semaphore:

  PROTECTED TYPE aMutex IS
    ENTRY LockMutex;
    PROCEDURE UnlockMutex;
  PRIVATE
    isLocked : BOOLEAN := FALSE;
  END aMutex;

  PROTECTED BODY aMutex IS
    ENTRY LockMutex WHEN NOT isLocked IS
    BEGIN
      isLocked := TRUE;
    END LockMutex;
    PROCEDURE UnlockMutex IS
    BEGIN
      isLocked := FALSE;
    END UnlockMutex;
  END aMutex;

  To create an instance of the protected type:

  SPIO2_RESOURCE_LOCK : aMutex;

  ...
  To obtain exclusive access to the resource:

  SPIO2_RESOURCE_LOCK.LockMutex;


  To release the resource:

  SPIO2_RESOURCE_LOCK.UnlockMutex;

I hope this helps,
SteveD


Robert Kershaw, KG4ASZ <NOSPAM_kg4asz@arrl.net> wrote in message
news:1rUZOBNgrjUOCSMI4WnzEyyo2oMj@4ax.com...
> I need to update an Ada applications which was written using the Alsys
> Ada 83 compiler to now use the Green Hill's  AdaMULTI product and
> WindRiver's  VxWorks.
>
> The code has call to the Alsys's ARTK for resource management.
> Example, calls are:
>
> with ARTK;
>
> package EXAMPLE is
>
>    -- Set up analog resource so that only one task can call analog
> routines
>    -- at a time
>    ANALOG_RESOURCE : ARTK.RESOURCES.RESOURCE;
>
> ...
>
>
> Then later on when a resource is needed it uses the resource as shown
> here:
>
>       -- Start resource protection
>       SPIO2_READY := ARTK.RESOURCES.GET_RESOURCE
> (SPIO2_RESOURCE);
>
>
> ....
>
>          -- Release resource protection
>       ARTK.RESOURCES.FREE_RESOURCE (SPIO2_RESOURCE);
>
>
> How do I implement these same functions in Ada95?
>
> Does the AdaMULTI or VxWorks have equivalent functions?
>
> Does anyone have Alsys documentation on what these functions do?
>
> Thank You for your help,
>
> RSK
>
>
> ---------------------------------------------------
> NOSPAM_KG4ASZ@arrl.net
> Delete obvious anti-spam garbage from the address (if present) for proper
reply address.






           reply	other threads:[~1999-10-29  0:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1rUZOBNgrjUOCSMI4WnzEyyo2oMj@4ax.com>]
replies disabled

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