[cpp-threads] Slightly revised memory model proposal (D2300)

Nick Maclaren nmm1 at cus.cam.ac.uk
Tue Jun 5 21:44:10 BST 2007


"Alexander Terekhov" <alexander.terekhov at gmail.com> wrote:
> On 6/5/07, Lawrence Crowl <Lawrence at crowl.org> wrote:
> 
> > Is there any problem with the standard modeling the interrupt
> > as simply another thread?
> 
> POSIX has a mechanism for that[1]. But interrupts are no threads. An
> implementation can make volatile sig_atomic_t "interrupt safe" by
> simply disabling interrupts around accesses to volatile sig_atomic_t's
> in the accessing thread. No barriers and/or thread atomicity needed.
> 
> [1] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html
> 
> Multi-threaded programs can use an alternate event notification
> mechanism. When a notification is processed, and the sigev_notify
> member of the sigevent structure has the value SIGEV_THREAD, the
> function sigev_notify_function is called with parameter sigev_value.
> 
> The function shall be executed in an environment as if it were the
> start_routine for a newly created thread with thread attributes
> specified by sigev_notify_attributes. ...

Er, no, sorry.  That is one of the more horrific features of
POSIX, because it is an absolute nightmare to implement on most
platforms for many types of interrupt.

It is a perfectly good mechanism for handling external signals,
which often include things like device interrupts, timers, and all
that.  No problem.

But it is completely hopeless for anything that is intrinsically
bound up with the execution of the interrupted thread, such as TLB
misses, floating-point exceptions (whether fixups, IEEE 754 flagging
or SIGFPE) and SIGSEGV etc.


But that isn't the issue, anyway.

As far as the MEMORY model goes, it doesn't make a huge difference
to C++ whether the primary thread is interrupted and a handler run
in the same thread, or whether another thread is being executed.
Both need comparable specifications of atomicity, synchronisation
etc.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



More information about the cpp-threads mailing list