TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Tue, 2 Mar 2004 14:48:04 +0530
Content-Type:
text/plain
Parts/Attachments:
text/plain (227 lines)
hi alex,
            Shiva here. I have done a small program which uses protected
and 2 tasks. Check this, but this program works........

with Ada.Text_Io;
use  Ada.Text_Io;

procedure Protected_Task is
   protected Task_Var is
      procedure Increment;
   private
      A : Integer:=0;
   end Task_Var;

   protected body Task_Var is
      procedure Increment is
      begin
         A:=A+1;
         New_Line;
         Put(" A value :");
         Put(Integer'Image(A));
      end Increment;
   end Task_Var;


   task type A1 is
      entry Increment1;
   end A1;

   task body A1 is
   begin
      loop
         accept Increment1 do
            New_Line;
            Put(" Inside increment of task 1");
            Task_Var.Increment;
            New_Line;
         end Increment1;
      end loop;
   end A1;


   task type A2 is
      entry Increment2;
   end A2;

   task body A2 is
   begin
      loop
         accept Increment2 do
            New_Line;
            Put(" Inside increment of task 2");
            Task_Var.Increment;
            New_Line;
         end Increment2;
      end loop;
   end A2;

   Tsk1 : A1;
   Tsk2 : A2;
begin

   loop
      Tsk1.Increment1;
      Tsk2.Increment2;
      delay 1.0;
   end loop;
end Protected_Task;

I have also attached the program and the exe of it... This was done on GNAT
compiler, Ada gide editor

(See attached file: protected_task.adb)(See attached file:
protected_task.exe)


Regards,
shiva....!!
---------------------------------------------------------------------------
No.4, Service road, (Near) Shanthi sagar,
Domlur, Bangalore - 560 071.
Ph : 25350510 / 512 / 364 / 354  Extn : 208
---------------------------------------------------------------------------
( ) L&T Infotech Proprietary & Confidential
( ) L&T Infotech Confidential
( ) L&T Infotech Internal Use only
(+) General Business Information



Hi,

Could anybody help me with a tasking problem I am experiencing in ADA?

I have a protected object (PO), and when a single task accesses this PO,
then everything is fine.
As soon as I have more then one task trying to access the PO, the software
hangs as soon as the 2nd task trys to gain access.

What could cause this to happen?
All the tasks have the same priority.

Any advice would be greatly appreciated.

Cheers

Alex































This email may contain confidential or privileged information for the
intended recipient(s). If you are not the intended recipient, please do not
use or disseminate the information, notify the sender and delete it from
your system. Thanks

--0__=EABBE4D9DFB549838f9e8a93df938690918cEABBE4D9DFB54983
Content-type: application/octet-stream;
             name="protected_task.adb"
Content-Disposition: attachment; filename="protected_task.adb"
Content-Transfer-Encoding: base64

d2l0aCBBZGEuVGV4dF9JbzsNCnVzZSAgQWRhLlRleHRfSW87DQoNCnByb2NlZHVyZSBQcm90ZWN0

ZWRfVGFzayBpcyANCiAgIHByb3RlY3RlZCBUYXNrX1ZhciBpcw0KICAgICAgcHJvY2VkdXJlIElu

Y3JlbWVudDsgDQogICBwcml2YXRlDQogICAgICBBIDogSW50ZWdlcjo9MDsNCiAgIGVuZCBUYXNr

X1ZhcjsNCg0KICAgcHJvdGVjdGVkIGJvZHkgVGFza19WYXIgaXMNCiAgICAgIHByb2NlZHVyZSBJ

bmNyZW1lbnQgaXMgDQogICAgICBiZWdpbg0KICAgICAgICAgQTo9QSsxOw0KICAgICAgICAgTmV3

X0xpbmU7DQogICAgICAgICBQdXQoIiBBIHZhbHVlIDoiKTsNCiAgICAgICAgIFB1dChJbnRlZ2Vy

J0ltYWdlKEEpKTsNCiAgICAgIGVuZCBJbmNyZW1lbnQ7DQogICBlbmQgVGFza19WYXI7DQoNCg0K

ICAgdGFzayB0eXBlIEExIGlzDQogICAgICBlbnRyeSBJbmNyZW1lbnQxOyANCiAgIGVuZCBBMTsN

Cg0KICAgdGFzayBib2R5IEExIGlzDQogICBiZWdpbg0KICAgICAgbG9vcA0KICAgICAgICAgYWNj

ZXB0IEluY3JlbWVudDEgZG8gDQogICAgICAgICAgICBOZXdfTGluZTsNCiAgICAgICAgICAgIFB1

dCgiIEluc2lkZSBpbmNyZW1lbnQgb2YgdGFzayAxIik7DQogICAgICAgICAgICBUYXNrX1Zhci5J

bmNyZW1lbnQ7DQogICAgICAgICAgICBOZXdfTGluZTsNCiAgICAgICAgIGVuZCBJbmNyZW1lbnQx
Ow0KICAgICAgZW5kIGxvb3A7DQogICBlbmQgQTE7DQoNCg0KICAgdGFzayB0eXBlIEEyIGlzDQog

ICAgICBlbnRyeSBJbmNyZW1lbnQyOyANCiAgIGVuZCBBMjsNCg0KICAgdGFzayBib2R5IEEyIGlz

DQogICBiZWdpbg0KICAgICAgbG9vcA0KICAgICAgICAgYWNjZXB0IEluY3JlbWVudDIgZG8gDQog

ICAgICAgICAgICBOZXdfTGluZTsNCiAgICAgICAgICAgIFB1dCgiIEluc2lkZSBpbmNyZW1lbnQg

b2YgdGFzayAyIik7DQogICAgICAgICAgICBUYXNrX1Zhci5JbmNyZW1lbnQ7DQogICAgICAgICAg

ICBOZXdfTGluZTsNCiAgICAgICAgIGVuZCBJbmNyZW1lbnQyOw0KICAgICAgZW5kIGxvb3A7DQog

ICBlbmQgQTI7DQoNCiAgIFRzazEgOiBBMTsgIA0KICAgVHNrMiA6IEEyOyAgDQpiZWdpbg0KDQog

ICBsb29wDQogICAgICBUc2sxLkluY3JlbWVudDE7DQogICAgICBUc2syLkluY3JlbWVudDI7ICAg

ICAgDQogICAgICBkZWxheSAxLjA7DQogICBlbmQgbG9vcDsNCmVuZCBQcm90ZWN0ZWRfVGFzazs=

--0__=EABBE4D9DFB549838f9e8a93df938690918cEABBE4D9DFB54983--































This email may contain confidential or privileged information for the
intended recipient(s). If you are not the intended recipient, please do not
use or disseminate the information, notify the sender and delete it from
your system. Thanks

ATOM RSS1 RSS2