[comp.lang.ada] can not abort allocated tasks

nieh@moose.steinmetz (nico nieh) (10/09/87)

I am writing a simulation program using Ada task facilities.
What I wanted to do is to be able to abort a task which
is activated by using the allocator.

The program segment looks like,

 task type pool is
     entry draw(which : out integer); -- contains an infinite loop
 end
 type t_pool is access pool;
 pool_1 : t_pool;
 pool_2 : pool;
 begin
 ....
 ....
 pool_1 := new pool;
 ...
 ...
 abort pool_1;

However, both DEC/ADA and Verdix Ada compiler gave syntax error at the
abort statement.

According to the LRM,

   abort_statement  ::=  ABORT task_name {,task_name};
 
the abort statement only takes task_names not pointers to task.

Is there any way to abort task pool_1 ?














     Ko-Haw Nieh
     General Electric Company 
     Corporate Research and Development
     nieh@ge-crd.arpa
     518-387-7431

fitch@ada-uts (10/12/87)

By using ".all" you can refer to a task object via a pointer.
So you want to specify

    abort POOL_1.all;
    
If, however, this task does have an infinite loop, your abort
may not help you, since an "aborted" task may not become
completed until it hits a syncronization point, e.g. an accept
statement. Better to remove the loop and using a less severe
method to stop the task.

Geoff Fitch
Intermetrics, Inc.
733 Concord Ave.
Cambridge, MA 02138

jonab@CAM.UNISYS.COM (Jonathan P. Biggar) (10/12/87)

In article <7586@steinmetz.steinmetz.UUCP> nieh@moose.steinmetz (nico nieh) writes:
	task type pool is
	    entry draw(which : out integer); -- contains an infinite loop
	end
	type t_pool is access pool;
	pool_1 : t_pool;
	begin
	pool_1 := new pool;
	abort pool_1;
	
>Is there any way to abort task pool_1 ?

The statement you need is:

abort pool_1.all;

The '.all' component refers to the entire object accessed by the access
type.

Jon Biggar
jonab@cam.unisys.com

jb@rti.UUCP (Jeff Bartlett) (10/12/87)

How about

	abort task_1.all;

since you wanted to stop what the pointer references not stop the pointer.

Jeff Bartlett
Research Triangle Institute       jb@rti.rti.org    mcnc!rti!jb

claudio@ethz.UUCP (Claudio Nieder) (10/12/87)

In article <7586@steinmetz.steinmetz.UUCP> nieh@moose.steinmetz 
(nico nieh) writes:

>What I wanted to do is to be able to abort a task which
>is activated by using the allocator.
>
>... the abort statement only takes task_names not pointers to task.
 
So you have to dereference the pointer ... 

 procedure TASK_REFERENCE is

  task type TASK_TYPE;
  type TASK_POINTER is access TASK_TYPE;
  TASK_INSTANCE : TASK_POINTER;

  task body TASK_TYPE is
  begin
   null; -- may be a never ending story ...
  end TASK_TYPE;

 begin
  TASK_INSTANCE := new TASK_TYPE;
  abort TASK_INSTANCE.all;
 end TASK_REFERENCE;

... and your program will be accepted by the compiler.

						Harry
 

murphy@beatnix.UUCP (Michael Murphy) (10/13/87)

You need to dereference the task access, e.g.
	abort pool_1.all;
That way you are aborting the task rather than the access value.

-- Michael P. Murphy
-- UUCP: sun!elxsi!elky!murphy