From: "Jean-Pierre Rosen" <rosen@adalog.fr>
Subject: Re: Multiple entry tasks
Date: Thu, 19 Apr 2001 10:17:58 +0200
Date: 2001-04-19T10:17:58+02:00 [thread overview]
Message-ID: <9bm76r$mf6$1@s1.read.news.oleane.net> (raw)
In-Reply-To: 9bkevj$61k$1@nh.pace.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1730 bytes --]
"Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> a �crit dans
le message news: 9bkevj$61k$1@nh.pace.co.uk...
> Sounds like you want some version of guarded entries in a select
statement.
> I have not attempted to do this before (kids: don't try this at home - we
> *are* trained professionals!), nor have I run this past a compiler (spank
me
> for this later if it doesn't work) but I *think* you want some version of
> the following:
>
> select
> when (Entry2'Count <= 0) and (Entry1'Count <= 0) =>
> accept Entry3 ;
> when (Entry1'Count <= 0) =>
> accept Entry2 ;
> or
> accept Entry1;
> else
> terminate;
> end select ;
>
This is wrong. Guards are evaluated only when the select is entered (unlike
POs), therefore if a task cancels its call (through timed entry call) while
the guards are being evaluated, you may end up in a situation of infinite
blocking.
The 'Count attribute should be used only with great care outside a PO. The
proper way of checking if a queue is empty is to use the else part of the
select statement. Therefore:
select
accept Entry1;
else
select
accept Entry2;
else
select
accept Entry1;
or
accept Entry2;
or
accept Entry3;
or
terminate;
end select;
end select;
end select;
Now, an exercise to see who is following. Those who attended an Adalog
training session are excluded from the competition :-)
1) Show that the sequence above exhibits a race condition
2) Show that the race condition is perfectly acceptable.
--
---------------------------------------------------------
J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
next prev parent reply other threads:[~2001-04-19 8:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-18 14:57 Multiple entry tasks Lutz Donnerhacke
2001-04-18 16:22 ` Marin David Condic
2001-04-18 18:12 ` Ted Dennison
2001-04-18 18:57 ` Ted Dennison
2001-04-18 20:16 ` Marin David Condic
2001-04-19 14:02 ` Ted Dennison
2001-04-19 14:28 ` Marin David Condic
2001-04-18 19:46 ` Marin David Condic
2001-04-19 21:52 ` Robert A Duff
2001-04-24 9:19 ` Lutz Donnerhacke
2001-04-19 8:17 ` Jean-Pierre Rosen [this message]
2001-04-19 14:42 ` Ted Dennison
2001-04-19 15:01 ` Marin David Condic
2001-04-19 15:02 ` Jean-Pierre Rosen
2001-04-19 19:12 ` Ted Dennison
2001-04-20 14:17 ` Jean-Pierre Rosen
2001-04-20 19:04 ` Ted Dennison
2001-04-23 6:55 ` Jean-Pierre Rosen
2001-04-23 13:50 ` Ted Dennison
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox