comp.lang.ada
 help / color / mirror / Atom feed
* I don't know what the compiler wants to tell me
@ 2005-11-03 20:47 Thomas Ruschival
  2005-11-03 22:39 ` jimmaureenrogers
  2005-11-04  5:12 ` I don't know what the compiler wants to tell me Jeffrey R. Carter
  0 siblings, 2 replies; 8+ messages in thread
From: Thomas Ruschival @ 2005-11-03 20:47 UTC (permalink / raw)


Hi Group
I just wrote a sample program in which I wanted to understand how it works
with task type and instatiating tasks of that type. 
Now I run into a strange Compiler error I don't understand:

hello2b.adb:48:18: left hand of assignment must not be limited

Basically all I wanted to do is have a task running until another task
does a rendevouz and interrupts exactly that task. I wanted it
configurable so I first chose to configure it in the disciminants which
didn't work. 
Now I pass the task to be controlled at a rendevouz point to
the controller, this should copy it into a local variable to keep the
rendevouz as short as possible and then control the task to which the local
variable points to.... as I write this the question arises: does ada pass
by value or by reference?

I appreciate any comments on how you do rendevous with task you don't know
yet at the time of writing, lets say you just know the access points of
that task type but you want to make rendevous with different instances of
that type, so you need to tell this either at point where you instantiate
the task that calls the entry point or at another point you have to tell
the task which object to meet


Thanks 
Thomas Ruschival


Here is the code: 
with Text_IO, Calendar;
use Calendar;

procedure Hello2b is
    
   task type PrinterTask is
	  entry Interrupt;
   end PrinterTask;
   
   task type ControlTask is
	  entry Start(ToControl : in PrinterTask);
   end ControlTask;
   
------ Hello Task to do the important work of printing "Hello" to
Console task body PrinterTask is
      SamplingTime : Duration := 2.0; 
      NextActivation : Calendar.Time ;
	  irq  : Boolean := False;
   begin
      while Irq = False  -- infinite loop until an external task does 
						 -- a rendevouz to
interrupt loop
		 -- next activation will be SamplingTime from now
		 NextActivation := Clock + SamplingTime; 
		 -- either interrupt occurs or we wait until 
		 -- samplingTime is elapsed and print Hello
		 select 
			accept Interrupt;
			  Irq := True;
		 or  		   
			delay until NextActivation;	
			Text_IO.Put_Line("task running");
		 end select;
      end loop;
   end PrinterTask;

------ ControlTask to interrupt the work of a given Task
   task body ControlTask is 
	  Controlled : PrinterTask; -- task To be controlled
   begin
	  -- Copy into local variable
	  accept Start(ToControl : in PrinterTask) do
		 Controlled := ToControl;
	  end Start;	 
		 
	  delay 60.0; -- wait a minute
	 Controlled.Interrupt; -- Now make a rendevouz with the task we
want to terminate end ControlTask;	  
    
-- tasks   
   Printer :  PrinterTask;
   Controller: ControlTask; 
   
begin
   Text_IO.Put_Line("Procedure running....");
   Controller.Start(Printer);
end Hello2b;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-08 19:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-03 20:47 I don't know what the compiler wants to tell me Thomas Ruschival
2005-11-03 22:39 ` jimmaureenrogers
2005-11-08  8:43   ` Thomas Ruschival
2005-11-08 19:30     ` Ada books (was: I don't know what the compiler wants to tell me) Björn Persson
2005-11-04  5:12 ` I don't know what the compiler wants to tell me Jeffrey R. Carter
2005-11-04  9:14   ` Lurker
2005-11-04 17:55     ` Martin Krischik
2005-11-07  8:32       ` Maciej Sobczak

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