comp.lang.ada
 help / color / mirror / Atom feed
* GNAT DOS Delay Problems
@ 1997-09-26  0:00 Gert Caspersen
  1997-09-27  0:00 ` juan carlos diaz martin
  1997-09-29  0:00 ` Samuel T. Harris
  0 siblings, 2 replies; 3+ messages in thread
From: Gert Caspersen @ 1997-09-26  0:00 UTC (permalink / raw)




When running the below program, no context switch takes place. Task T1 with
the low priority is starved by task T2 with the high priority.

In my opinion, T1 should be scheduled when T2 executes delay 10.0. However,
this appears never to happen. Rather, the entire program is suspended for
ten seconds.

I am using GNAT version 3.07 for DOS.

Any ideas of the cause would be appreciated....

with Ada.Text_IO;
procedure Dims is

   task T1 is
      pragma Priority (2);
   end T1;

   task T2 is
      pragma Priority (3);
   end T2;

   task body T1 is
   begin  -- T1
      loop
         Ada.Text_IO.Put_Line("Task 1");
         delay (1.0);
      end loop;
   exception
      when others =>
         Ada.Text_IO.Put_Line("Task 1 got exception");
   end T1;

   task body T2 is
   begin  -- T2
      loop
         Ada.Text_IO.Put_Line("Task 2");
         delay (10.0);
      end loop;
   exception
      when others =>
         Ada.Text_IO.Put_Line("Task 2 got exception");
   end T2;

begin  -- Dims
   null;
end Dims;





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

* Re: GNAT DOS Delay Problems
  1997-09-26  0:00 GNAT DOS Delay Problems Gert Caspersen
@ 1997-09-27  0:00 ` juan carlos diaz martin
  1997-09-29  0:00 ` Samuel T. Harris
  1 sibling, 0 replies; 3+ messages in thread
From: juan carlos diaz martin @ 1997-09-27  0:00 UTC (permalink / raw)



Gert Caspersen wrote:
> 
> When running the below program, no context switch takes place. Task T1 with
> the low priority is starved by task T2 with the high priority.
> 
> In my opinion, T1 should be scheduled when T2 executes delay 10.0. However,
> this appears never to happen. Rather, the entire program is suspended for
> ten seconds.
> 
> I am using GNAT version 3.07 for DOS.

Gert:
I have tested your program in GNAT for Windows95/NT and goes ok! My
experience with GNAT DOS (3.05 and 3.07)  has been terrifying. It's a
pitty but Forget DOS GNAT at all. It does not implementes Ada pretty
well.




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

* Re: GNAT DOS Delay Problems
  1997-09-26  0:00 GNAT DOS Delay Problems Gert Caspersen
  1997-09-27  0:00 ` juan carlos diaz martin
@ 1997-09-29  0:00 ` Samuel T. Harris
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel T. Harris @ 1997-09-29  0:00 UTC (permalink / raw)



Gert Caspersen wrote:
> 
> When running the below program, no context switch takes place. Task T1 with
> the low priority is starved by task T2 with the high priority.
> 
> In my opinion, T1 should be scheduled when T2 executes delay 10.0. However,
> this appears never to happen. Rather, the entire program is suspended for
> ten seconds.
> 
> I am using GNAT version 3.07 for DOS.
> 
> Any ideas of the cause would be appreciated....
> 
> with Ada.Text_IO;
> procedure Dims is
> 
>    task T1 is
>       pragma Priority (2);
>    end T1;
> 
>    task T2 is
>       pragma Priority (3);
>    end T2;
> 
>    task body T1 is
>    begin  -- T1
>       loop
>          Ada.Text_IO.Put_Line("Task 1");
>          delay (1.0);
>       end loop;
>    exception
>       when others =>
>          Ada.Text_IO.Put_Line("Task 1 got exception");
>    end T1;
> 
>    task body T2 is
>    begin  -- T2
>       loop
>          Ada.Text_IO.Put_Line("Task 2");
>          delay (10.0);
>       end loop;
>    exception
>       when others =>
>          Ada.Text_IO.Put_Line("Task 2 got exception");
>    end T2;
> 
> begin  -- Dims
>    null;
> end Dims;

I remember using both Janus and Alsys Ada on PC before
they implementing time-slicing. Once a task took over,
it had control until it terminated or initiated a
rendevous. The run-time scheduler NEVER interrupted
the running task and only "scheduled" the next task
when a task terminated or a rendevous occured.

To get around that problem, I used a nil_task with
a single accept which basically did nothing. I then
"spinkled" the actual tasks and the main program with
entry calls to that do_nothing entry. This gave the
scheduler a chance to switch amoung the various tasks
in the system. Placement of these "scheduler" rendevous
was a black art and some playing around was needed to
get the desired behavior.

-- 
Samuel T. Harris, Senior Engineer
Hughes Training, Inc. - Houston Operations
2224 Bay Area Blvd. Houston, TX 77058-2099
"If you can make it, We can fake it!"




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

end of thread, other threads:[~1997-09-29  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-26  0:00 GNAT DOS Delay Problems Gert Caspersen
1997-09-27  0:00 ` juan carlos diaz martin
1997-09-29  0:00 ` Samuel T. Harris

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