comp.lang.ada
 help / color / mirror / Atom feed
[parent not found: <E15KOgZ-0001Jc-00@beatrice.spick.nowhdus>]
[parent not found: <E15JwDj-00077I-00@beatrice.spick.nowhdus>]
[parent not found: <E15F7Ws-00038J-00@beatrice.spick.nowhdus>]
* Simple Producer/Consumer with Annex E
@ 2001-06-19 20:00 Frank
  2001-06-26 20:45 ` Frank
  0 siblings, 1 reply; 17+ messages in thread
From: Frank @ 2001-06-19 20:00 UTC (permalink / raw)


Hi!

I'm trying to create two "main" like procedures, one in each partition.
These two procedures shall communicate with a task in a package placed in a
third partition.
In a third partition I place a package that contains a task (called SERVER).
This server
initialize a buffer variable CURRENT_VALUE to 1000.

One of the procedures (P_SENDER) shall send two values to the server, and
change the CURRENT_VALUE.
The other procedure (P_RECEIVER) shall get the CURRENT_VALUE in the task.
The receiver has a loop that prints the value it get from the server, this
in order to see the progress.
As the code is now, I start the server (executable get the name:
PART_SERVER) first, and then I start the receiver (executable get the name:
PART_RECEIVER). The receiver starts printing 1000...1000...
Then I start the sender (executable get the name: PART_SENDER).

What I experience is that only the first of the values (123) I wish to send
is received at the receiver, and the next value is never passed.

In the configuration file; I have established the P_RECEIVER procedure as
the applications main procedure (which is placed in PART_RECEIVER), then I
have established P_SENDER as a 'Main for partition PART_SENDER.
I have done some experiments with this code, and have a hunch that it is the
sender that for some reason dosn't send the next value.

I wonder if this is caused by the "for PART_SENDER'Main use P_SENDER"
construction, that might not work as a believe?
I believed that the 'Main construction would give me another "main", in the
sense that if I switched the roles of the to (P_RECEIVER and P_SENDER) that
should give me the same functionality. Is this nonsense?

I have also considered the 'Task_Pool setting, but haven't quite succeded in
setting it. Does the compiler use some default values that gives me this
situation?

Does anyone have any suggestions?

(Makefile, P_SENDER, P_RECEIVER and PA_SERVER is added to this posting)

Frank


-----------------------------------------
configuration SENDER_SERVER_RECEIVER is

     PART_RECEIVER : Partition := (P_RECEIVER);
     for PART_RECEIVER'Host use "localhost";
     procedure P_RECEIVER is in PART_RECEIVER;


     PART_SENDER : Partition := (P_SENDER);
     for PART_SENDER'Host use "localhost";
     procedure P_SENDER;
     for PART_SENDER'Main use P_SENDER;

     PART_SERVER : Partition := (PA_SERVER);
     for PART_SERVER'Host use "localhost";

     pragma Starter (None);

end SENDER_SERVER_RECEIVER;
-----------------------------------------
with PA_SERVER;
with TEXT_IO;
procedure P_SENDER is

begin

  PA_SERVER.SEND (123);
  PA_SERVER.SEND (124);

end P_SENDER;
-----------------------------------------
with PA_SERVER;
with TEXT_IO;
procedure P_RECEIVER is
  RECEIVED : INTEGER;

begin
  PA_SERVER.START_SERVER;
  TEXT_IO.PUT_LINE ("Server has been started");
  loop
    PA_SERVER.RECEIVE (RECEIVED);
    TEXT_IO.PUT_LINE ("Received = " & RECEIVED'Img);
  end loop;

end P_RECEIVER;
-----------------------------------------
with TEXT_IO;
package body PA_SERVER is

  task type TYPE_TASK_SERVER is

    entry START_SERVER;

    entry RECEIVE ( P_RECEIVE : out INTEGER);
    entry SEND ( P_SEND : in INTEGER);

  end TYPE_TASK_SERVER;

  task body TYPE_TASK_SERVER is
    RUNNING : BOOLEAN := FALSE;

    CURRENT_VALUE : INTEGER;

  begin

    CURRENT_VALUE := 1000;


    accept START_SERVER do
      RUNNING := TRUE;

    end START_SERVER;

    while RUNNING loop
      select
       accept RECEIVE (P_RECEIVE : out INTEGER) do
          P_RECEIVE := CURRENT_VALUE;

        end RECEIVE;

      or
        accept SEND (P_SEND : in INTEGER) do
          CURRENT_VALUE := P_SEND;

        end SEND;

      end select;


    end loop;

  end TYPE_TASK_SERVER;

  SERVER : TYPE_TASK_SERVER;

  procedure RECEIVE (P_RECEIVE : out INTEGER)
  is
  begin
    SERVER.RECEIVE (P_RECEIVE);

  end RECEIVE;

  procedure SEND (P_SEND : in INTEGER)  is
  begin
    SERVER.SEND (P_SEND);
  end SEND;

  procedure START_SERVER is
  begin
    SERVER.START_SERVER;
  end START_SERVER;

end PA_SERVER;
-------------------------------------
package PA_SERVER is
  pragma Remote_Call_Interface;

  procedure RECEIVE (P_RECEIVE : out INTEGER);


  procedure SEND (P_SEND : in INTEGER);

  procedure START_SERVER;

end PA_SERVER;

-------------------------------------
Makefile
all:
 gnatdist -v sender_server_receiver.cfg `gtkada-config`

clean:
 rm -rf *.o *.ali dsa







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

end of thread, other threads:[~2001-07-17 18:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200107111927240390.00071225@smtp-po.inetia.pl>
2001-07-11 18:26 ` Simple Producer/Consumer with Annex E Wilhelm Spickermann
     [not found] <E15KOgZ-0001Jc-00@beatrice.spick.nowhdus>
2001-07-11 20:13 ` Michal Nowak
     [not found] <E15JwDj-00077I-00@beatrice.spick.nowhdus>
2001-07-11 17:27 ` Michal Nowak
     [not found] <E15F7Ws-00038J-00@beatrice.spick.nowhdus>
2001-07-03 17:02 ` Michal Nowak
2001-07-07  9:13   ` Frank
2001-07-10  7:52     ` Frank
2001-07-10 12:02       ` Wilhelm Spickermann
2001-07-10 15:04         ` Frank
2001-07-15 12:45           ` Michal Nowak
2001-07-16 17:26             ` Ted Dennison
2001-07-16 21:16               ` David C. Hoos
2001-07-16 21:41                 ` Ted Dennison
     [not found]               ` <094701c10e3c$917512c0$453ab4d8@sy.com>
2001-07-17 18:33                 ` Michal Nowak
2001-06-19 20:00 Frank
2001-06-26 20:45 ` Frank
2001-06-27  5:06   ` Wilhelm Spickermann
2001-06-28  7:07     ` Frank

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