comp.lang.ada
 help / color / mirror / Atom feed
From: Larry Coon <larry@assist.org>
Subject: Array of tasks
Date: 1997/12/09
Date: 1997-12-09T00:00:00+00:00	[thread overview]
Message-ID: <348D7832.27A4@assist.org> (raw)


I posted a similar question from home a few days ago,
and didn't see a response.  I checked from work and
didn't see my original question, so I'm posting again
just in case something happened to my original post.
My apologies if you've already seen this.

I have an array of tasks and an array of semaphores.
The size of both arrays are set at runtime (based on
user input).  I can't figure out a way to make the
array of semaphores visible to the array of tasks.

Here's some contrived code to illustrate what I'm
trying to do:

procedure main is
  protected type semaphore is
    entry seize;
    procedure release;
  private
    available:	boolean := true;
  end semaphore;

  -- The usual implementation of a semaphore.
  protected body semaphore is separate;

  task type t;
  task body t is separate;

  task_count: positive;
begin -- main
  put ("Enter number of tasks: ");
  get (task_count);
  declare
    subtype task_range is integer range 1..task_count;
    semaphore_array: array (task_range) of semaphore;
    task_array: array (task_range) of t;
  begin
    null;
  end;
end;

Within the body of task T I want to access a semaphore in
semaphore_array.  It won't compile, saying the semapore
array is not visible.

How do I declare things so the tasks can see the semaphores?
I've tried nested blocks, and I've tried passing pointers
to the semaphores, but couldn't get anything to work right.
Thanks in advance for any help.

Larry Coon
University of California
larry@assist.org
and lmcoon@home.com




             reply	other threads:[~1997-12-09  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-12-09  0:00 Larry Coon [this message]
1997-12-09  0:00 ` Array of tasks Stephen Leake
1997-12-09  0:00   ` Larry Coon
1997-12-10  0:00     ` Mats Weber
1997-12-10  0:00 ` Anonymous
1997-12-10  0:00 ` Jean-Pierre Rosen
replies disabled

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