comp.lang.ada
 help / color / mirror / Atom feed
* gnat Dynamic Priority Dispatching Anomalies
@ 2003-02-04 12:04 Ian Broster
  0 siblings, 0 replies; only message in thread
From: Ian Broster @ 2003-02-04 12:04 UTC (permalink / raw)


Hello

I've noticed some anomalies with dynamic priorites and task dispatching
with gnat 3.15p, using both FSU threads and the native (linux) threads. It
seems that the highest priority runnable task does not always execute.

I have produced a test program which demonstrates the problem.
Can someone explain whether it is my misunderstanding or
whether it is a compiler/runtime problem.

The test programs are below, but I've also bundled them together at 
http://www-users.cs.york.ac.uk/~ianb/pub/gnatdispatching.tgz

The program output (with FSU threads) is below.
The first number in each line is the (dynamic) base priority, 
the second field is the task ID.

So the question is: at lines 4 and 6, why is a low priority (1)
task running when there is a high priority task (15) still
ready to execute?

 15  main_task_080921A8  Main started
 15  t1_08092888  Before set_priority
 15  main_task_080921A8  t1 made
 1  t1_08092888  After set_priority
 15  t2_0809AE60  Before set_priority
 1  t1_08092888  After delay
 15  main_task_080921A8  t2 made
 1  t2_0809AE60  After set_priority
 1  t2_0809AE60  After delay

Thanks for any help

Ian Broster



Program and version information follows.

Compiler version: (binary distribution)
GNAT 3.15p  (20020523) Copyright 1996-2002 Free Software Foundation, Inc.

uname:
Linux x 2.4.18 #14 SMP Fri Aug 30 14:37:42 BST 2002 i686 unknown


with text_io; use text_io;
with tasks; use tasks;

procedure main is
	t1 : athread_p;
	t2 : athread_p;
begin
	info("Main started");
	t1 := new athread;
	info("t1 made");
	t2 := new athread;
	info("t2 made");
end main;

package tasks  is
	procedure info(s: string);

	task type athread;
	type athread_p is access athread;
end tasks;


with Ada.Dynamic_Priorities; 
with system; use system;
with text_io; use text_io;
with Ada.Task_Identification; 

package body tasks  is
	procedure info(s: string) is
	begin
		put(Integer'image(Ada.Dynamic_Priorities.Get_Priority));
		put("  " );
		put(
			Ada.Task_Identification.Image(
				Ada.Task_Identification.Current_Task)
		);
		put("  ");
		put_line(s);
	end info;
	
	task body athread is
	begin
		info("Before set_priority");
		Ada.Dynamic_Priorities.Set_Priority(priority'first+1);
		info("After set_priority");
		delay 0.0;
		info("After delay");
		loop
			delay 0.0;
		end loop;
	end athread;

end tasks;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-04 12:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-04 12:04 gnat Dynamic Priority Dispatching Anomalies Ian Broster

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