【发布时间】:2016-09-17 09:08:13
【问题描述】:
提前感谢您的帮助。我目前正在做一些关于 ada 编程的初学者工作,我已经从http://libre.adacore.com/download/configurations# 安装了 GNAT Programming Studio (GPS) 我有 Windows 10 64 位。我在学校得到了以下代码:
pragma Task_Dispatching_Policy(FIFO_Within_Priorities);
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Real_Time; use Ada.Real_Time;
procedure PeriodicTasks is
Start : Time;
package Duration_IO is new Ada.Text_IO.Fixed_IO(Duration);
package Int_IO is new Ada.Text_IO.Integer_IO(Integer);
task type T(Id: Integer; Period : Integer) is
pragma Priority(Id);
end;
task body T is
Next : Time;
X : Integer;
begin
Next := Start;
loop
Next := Next + Milliseconds(Period);
-- Some dummy function
X := 0;
for Index in 1..5000000 loop
X := X + Index;
end loop;
Duration_IO.Put(To_Duration(Clock - Start), 3, 3);
Put(" : ");
Int_IO.Put(Id, 2);
Put_Line("");
delay until Next;
end loop;
end T;
-- Example Task
Task_P10 : T(10, 250);
Task_P12 : T(12, 500);
Task_P14 : T(14, 500);
Task_P16 : T(16, 250);
Task_P18 : T(18, 500);
Task_P20 : T(20, 250);
begin
Start := Clock;
null;
end PeriodicTasks;
我在 GPS 中打开文件,构建它(没有错误)并运行它,但它没有显示任何打印输出。我听说有时你会遇到多核 CPU 的问题,所以每次打开 gps.exe 时,CPU 关联设置为只有一个 CPU,并且总是“以管理员身份运行”。但是,这也不起作用,我没有输出。 我决定使用 Oracle Virtual Box 并设置一个只有一个处理器的 Ubuntu OS(32 位)。安装了 GNAT 工具,用 gnatmake 编译,用 ./periodictasks 运行,猜猜看,程序做了它应该做的事情并打印出信息。
经过这么长的故事,有人知道为什么会这样吗?会不会是 64 位 vs 32 位的情况?
非常感谢!
【问题讨论】:
标签: linux windows cpu ada affinity