From: "Pieter Thysebaert" <pieter.thysebaert@pandora.be>
Subject: (Newbie) intertask communication
Date: Fri, 06 Apr 2001 17:37:26 GMT
Date: 2001-04-06T17:37:26+00:00 [thread overview]
Message-ID: <q9nz6.15400$ii5.1263786@afrodite.telenet-ops.be> (raw)
Hi....
I'm trying to have two tasks interact (using entry/accept).
In fact we have this assignment where we are supposed to (not in reality)
monitor some patient's heartbeat.
So I created two task types : patient and monitor
The idea is that the patient will call the function (entry) beat on his/her
associated monitor;
the monitor will accept beat() calls and will display a warning when not
receiving a heartbeat for two (or x) seconds
So this is my monitor:
task body monitortask is
id : Integer;
begin
accept start(patient_id : Integer) do
id := patient_id;
end;
loop
select
accept beat do
PutLine(<patient id is alivestuff>);
end;
or
delay 2;
sound_alarm();
end loop;
end monitortask;
And the patient :
task body patienttask is
begin
accept start(m : monitortask) do
loop
delay <random value between 1 and 4 seconds>;
m.beat;
end loop;
end;
end patienttask;
My problem/question is : this stuff only works when m.start is called first
in a testprogram, end then p.start
(m : monitortask and p : patientask) - the testprogram blosk on the
patient.start thing
That's because I have the loop _IN_ the patient's accept statement.
Of course what I want is more like :
task body patienttask is
mymonitor : monitortask;
begin
accept start(m : monitortask) do
mymonitor := m;
end;
loop
.....do stuff but call mymonitor.beat;
which will not block the testprogram calling p.start;
Unfortunately, the assignment to mymonitor does not work like this.
How would I pass the "name" of a task to antoher task to have it use that
one ?
And how can I save a "reference"to a task ?
Pieter
next reply other threads:[~2001-04-06 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-06 17:37 Pieter Thysebaert [this message]
2001-04-06 20:46 ` (Newbie) intertask communication Mark Lundquist
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox