Fwd: Re: C++ Threading Proposal

Andrei Alexandrescu andrei at metalanguage.com
Mon Sep 27 22:17:28 BST 2004


Hans: Good to hear someone has studied Ada's concurrency model!

I forward one onther message from Jim Rogers. He makes the point that 
interrupts are a slightly different beast than threads, and should be 
part of the focus of our proposal.


Andrei

-------- Original Message --------
Return-Path: 	<jimmaureenrogers at att.net>
Received: 	from m1.dnsix.com ([63.251.171.163] verified) by
moderncppdesign.com (CommuniGate Pro SMTP 4.2b5) with ESMTP id 1261613
for a at moderncppdesign.com; Sun, 26 Sep 2004 08:17:19 -0700
Received: 	from [204.127.131.115] (helo=mtiwmhc11.worldnet.att.net) by
m1.dnsix.com with esmtp (Exim 4.24) id 1CBam6-0006iz-PA for
andrei at metalanguage.com; Sun, 26 Sep 2004 08:17:18 -0700
Received: 	from homefvra93mfsq
(80.denver-05rh15-16rt.co.dial-access.att.net[12.73.180.80]) by
worldnet.att.net (mtiwmhc11) with SMTP id <2004092615171611100a8od9e>;
Sun, 26 Sep 2004 15:17:17 +0000
Message-ID: 	<000901c4a3db$f09246a0$50b4490c at homefvra93mfsq>
From: 	Jim Rogers <jimmaureenrogers at att.net>
To: 	Andrei Alexandrescu <andrei at metalanguage.com>
Subject: 	Interrupt Handling and Threads
Date: 	Sun, 26 Sep 2004 09:17:28 -0600
MIME-Version: 	1.0
Content-Type: 	multipart/mixed;
boundary="----=_NextPart_000_0005_01C4A3A9.A51EDBC0"
X-Priority: 	3
X-MSMail-Priority: 	Normal
X-Mailer: 	Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: 	Produced By Microsoft MimeOLE V6.00.2800.1441



Andre,

Your recent posting concerning threading through the disabling of
interrupts stimulated my mind. Interrupts do have interesting
interactions with threaded applications.

Your C++ threading model should specify how that interaction is defined
by the programmer.

My personal point of view is that Threads and interrupts are two kinds
of concurrency. Simply concentrating on Threads and ignoring interrupts
is short sighted and will cause problems for programs designed to deal
with both Threads and interrupts.

I have attached three files demonstrating the Ada solution to this problem.

Ada uses a protected procedure to respond to a specified interrupt. The
relationship between the protected procedure and the interrupt is
established by the "pragma Attach_Handler" line in the file
"handler.ads". In my example, the task Responder calls the protected
entry Wait_For_Interrupt.  Responder can only get past the entry
boundary after at least one interrupt has been received by the protected
procedure Increment.

This arrangement ensures that Responder is the only task that will ever
respond to the interrupt, and it will always respond to the interrupt.
The "main" procedure for this program is Handler_Test. Handler_Test runs
in the environment task, and is therefore a separate task from Responder.
The only explicit connection between Handler_Test and Responder is the
call that Handler_Test makes to stop Responder.

The Responder task conditionally calls Wait_For_Interrupt with a 0.001
second timeout. If the timeout expires, Responder checks to see if its
Stop entry has been called. If the Stop entry has not been called
Responder loops back and again calls Wait_For_Interrupt. If the Stop
entry has been called Responder exits its basic loop and terminates.

Jim Rogers








More information about the cpp-threads mailing list