[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cma

Title:DECthreads Conference
Moderator:PTHRED::MARYSTEON
Created:Mon May 14 1990
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1553
Total number of notes:9541

1546.0. "alertable dequeue call?" by SPECXN::DERAMO (Dan D'Eramo) Tue May 20 1997 15:55

        [Digital UNIX V3.0 and later, OpenVMS V6.2 and later.]
        
        I need to be able to alert my thread that is blocked in a
        call to
        
        	cma_lib_queue_dequeue
        
        What is the cleanest way to do this?
        
        Thread A alerts thread B at a time when thread B is blocked in
        a call to cma_lib_queue_dequeue().  It may be weeks :-) before
        thread C finally gets around to enqueueing something on the
        queue.  Thread A knows nothing about the existence of thread C.
        
        How best can I cleanly get thread B to process the cma_e_alerted
        exception when it is given, without thread B having to wait
        for thread C to enqueue something for it?
        
        Dan
T.RTitleUserPersonal
Name
DateLines
1546.1Yep, it's alertable.WTFN::SCALESDespair is appropriate and inevitable.Tue May 20 1997 16:2511
.0> How best can I cleanly get thread B to process the cma_e_alerted
.0> exception when it is given, without thread B having to wait
.0> for thread C to enqueue something for it?

What makes you think that thread C has to enqueue something in order for 
thread B to receive the alert?  Unless thread B has alerts disabled, the alert
should awaken thread B as soon as it is sent, and thread B should (more or less)
immediately receive the alerted exception.


				Webb
1546.2SPECXN::DERAMODan D'EramoTue May 20 1997 16:3815
        But cma_lib_queue_dequeue is not a cancelation point...
        
        Section 2.7 "Thread Cancelation" of the March 1994 Guide to
        DECthreads lists the cancelation points and it isn't in the
        list; its individual man page mentions nothing of being a
        cancelation point either.
        
        Is it safe to call cma_alert_enable_asynch() immediately before
        cma_lib_queue_dequeue() and cma_alert_disable_asynch()
        immediately after?
        
        Or are you saying the documentation is incomplete and
        cma_lib_queue_dequeue() really is a cancelation point?
        
        Dan
1546.3DCETHD::BUTENHOFDave Butenhof, DECthreadsTue May 20 1997 17:1432
>        But cma_lib_queue_dequeue is not a cancelation point...
>        
>        Section 2.7 "Thread Cancelation" of the March 1994 Guide to
>        DECthreads lists the cancelation points and it isn't in the
>        list; its individual man page mentions nothing of being a
>        cancelation point either.

The cma_lib_ routines aren't "first class citizens" -- they're not part of
POSIX, DCE threads, or CMA. They're add-ons. Therefore they're not listed in
the (architectural) list of cancellation points.

The individual routine descriptions probably should have pointed out which
are cancellation points -- but this is moot now, since the most recent
published version of the manual no longer includes the CMA, CMA_LIB, or DCE
thread functions, and they won't be restored.

In fact, cma_lib_queue_dequeue is a cancellation point, so "'ave at it."

>        Is it safe to call cma_alert_enable_asynch() immediately before
>        cma_lib_queue_dequeue() and cma_alert_disable_asynch()
>        immediately after?
 
Never. NO functions in DECthreads are async cancel safe except the functions
that disable async cancellation! And don't count on any other functions,
anywhere, ever, being async cancel safe.
       
>        Or are you saying the documentation is incomplete and
>        cma_lib_queue_dequeue() really is a cancelation point?

Yes. As I said, there is no reasonable way to address this omission at the
current time. And since you're the first one in 7 years or so to even ask, I
expect it'll not cause many people much difficulty.
1546.4SPECXN::DERAMODan D'EramoTue May 20 1997 18:2922
	Thanks!  That makes this change so much easier! :-)
        
        The loop had been controlling when a cancelation could
        occur, and in fact there was such a test just before
        dequeueing from the queue:
        
            cma_alert_enable_general(&alert_state);
            cma_alert_test();
            cma_alert_disable_general(&alert_state);
        
            cma_lib_queue_dequeue(&queue, &addr);
        
        So I changed the above to:
        
            cma_alert_enable_general(&alert_state);
            cma_alert_test();
            cma_lib_queue_dequeue(&queue, &addr);
            cma_alert_disable_general(&alert_state);
        
        and now it does immediately process the cma_e_alerted exception.
        
        Dan