* Waiting simultaneously on X event & VMS event flag?
@ 1994-07-18 16:55 Nicholas Young
1994-07-19 22:58 ` Dom Maddalone
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Nicholas Young @ 1994-07-18 16:55 UTC (permalink / raw)
Can anyone help, please ...
I have an Xt-based program running on OpenVMS/Alpha that needs to wait
simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
there an easy way to do this? Possibilities seem to be:
1) Use XtAppAddInput (best, because portable). Can the alternative input
source be made to wait on event flags?
2) Go below the X level and use something else. Is XNextEvent implemented
using QIOs, and if so can I both use them to get X events and also to wait
on event flags? Or does X use some obscure VMS mechanism?
3) [Last resort] Write a separate app/thread that sits there waiting for
the event flag and dispatches some sort of alternative input to the Xt
loop (see (1)).
Or is there a better way that I've missed?
Advice, pointers or sample code gratefully appreciated. Mail preferred;
I'll post the results if there is any interest.
Thanks,
Nicholas.
--
Nicholas Young. Opinions expressed above are mine, not Logica's.
I am often away; please mail me if you wish to be sure I see articles.
"'Macbeth' is a play written by a man who, on this occasion at least, if he had the talent, ought to have written a fairy tale." - J.R.R.Tolkien.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Waiting simultaneously on X event & VMS event flag?
1994-07-18 16:55 Waiting simultaneously on X event & VMS event flag? Nicholas Young
@ 1994-07-19 22:58 ` Dom Maddalone
1994-07-20 13:00 ` Tim Llewellyn
1994-07-21 13:35 ` Art Stine
1994-07-27 9:57 ` dominique dierick
2 siblings, 1 reply; 7+ messages in thread
From: Dom Maddalone @ 1994-07-19 22:58 UTC (permalink / raw)
In article <youngn-1807941655410001@158.234.17.99>, youngn@logica.co.uk (Nicholas Young) writes:
>I have an Xt-based program running on OpenVMS/Alpha that needs to wait
>simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
>there an easy way to do this? Possibilities seem to be:
>
>1) Use XtAppAddInput (best, because portable). Can the alternative input
>source be made to wait on event flags?
>
>2) Go below the X level and use something else [...]
>
>3) [Last resort] Write a separate app/thread that sits there [...]
Your first possibilty is my choice. Here's an example: it creates
a push button; activate it or wait for a timed AST to off 5 times and the
application ends.
Pay attention to the IOSB argument. Beware of the code too, very
fast and loose.
#include <descrip.h>
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
#define DOMs_EFN 21
#define DOMs_EXPIRATION "0 00:00:05"
struct io_status_block {
unsigned short condition;
unsigned short unused;
unsigned long also_unused;
} iosb;
/*
* Globals
*/
char *btn_text;
int daytim[2];
unsigned long reqidt;
XtInputId inputCallbackId;
/*
* Forward declarations
*/
void set_timer (void);
void set_efn (void);
void activateCB (Widget, caddr_t, caddr_t);
void timerInputCB(caddr_t, int *, XtInputId *);
main(int argc, char **argv)
{
Widget toplevel;
Widget button;
XtAppContext app_ctx;
Arg args[10];
int n;
register status;
$DESCRIPTOR(timbuf,DOMs_EXPIRATION);
toplevel = XtAppInitialize(&app_ctx,"Dom",NULL,0,&argc,argv,NULL,NULL,
0);
btn_text = XmStringCreateLtoR("Push Here\n\tor\nWait for timer",
XmSTRING_DEFAULT_CHARSET);
n = 0;
XtSetArg(args[n],XmNlabelString,btn_text); n++;
XtSetArg(args[n],XmNwidth,250); n++;
XtSetArg(args[n],XmNheight,150); n++;
button = XtCreateManagedWidget("button",xmPushButtonWidgetClass,toplevel,
args,n);
XtAddCallback(button,XmNactivateCallback,activateCB,NULL);
if (((status = SYS$BINTIM(&timbuf,&daytim)) &1) != 1)
LIB$SIGNAL(status);
(void) set_timer();
inputCallbackId = XtAppAddInput(app_ctx,DOMs_EFN,&iosb,timerInputCB,NULL);
XtRealizeWidget(toplevel);
XtAppMainLoop(app_ctx);
}
void set_timer(void)
{
register status;
/*
* The condition enables/disables the input callback:
* zero - disabled
* non zero - enabled
*
* Important: Do NOT disable the input callback AND set the event flag;
* it will put the application into a compute bound loop.
*/
SYS$CLREF(DOMs_EFN);
iosb.condition = 1;
/*
* Have an AST execute after a few seconds to set the event flag,
* which will kick off the input callback routine.
*/
if (((status = SYS$SETIMR(0,&daytim,set_efn,reqidt,0)) &1) != 1)
LIB$SIGNAL(status);
}
void set_efn(void)
{
SYS$SETEF(DOMs_EFN);
}
void activateCB(Widget w, caddr_t client_data, caddr_t call_data)
{
printf("PushButton selected.\n");
/*
* The button has been pushed so we don't want anything more to do with
* the input callback routine:
* unregister the input source callback
* cancel the outstanding timer
*/
XtRemoveInput(inputCallbackId);
SYS$CANTIM(reqidt,0);
XmStringFree(btn_text);
printf("Exiting\n");
exit(0);
}
void timerInputCB(caddr_t client_data, int *source, XtInputId *id)
{
static int count = 0;
count++;
printf("Timer expired %d\n",count);
/*
* For politeness' sake, disable the input callback
*/
SYS$CLREF(DOMs_EFN);
iosb.condition = 0;
if (count > 4) {
XmStringFree(btn_text);
printf("Exiting\n");
exit(0);
} else {
(void) set_timer();
}
}
Dom Maddalone, dgm@cronus.colorado.edu
System Administrator, University Physicians, Inc., Denver
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Waiting simultaneously on X event & VMS event flag?
1994-07-19 22:58 ` Dom Maddalone
@ 1994-07-20 13:00 ` Tim Llewellyn
0 siblings, 0 replies; 7+ messages in thread
From: Tim Llewellyn @ 1994-07-20 13:00 UTC (permalink / raw)
In article <1994Jul19.155807.1669@buckie.hsc.colorado.edu>,
dgm@cronus.colorado.edu (Dom Maddalone) writes:
|>
|>In article <youngn-1807941655410001@158.234.17.99>, youngn@logica.co.uk
|>(Nicholas Young) writes:
|>
|>>I have an Xt-based program running on OpenVMS/Alpha that needs to wait
|>>simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
|>>there an easy way to do this? Possibilities seem to be:
|>>
|>>1) Use XtAppAddInput (best, because portable). Can the alternative input
|>>source be made to wait on event flags?
|>>
|>>2) Go below the X level and use something else [...]
|>>
|>>3) [Last resort] Write a separate app/thread that sits there [...]
|>
|> Your first possibilty is my choice. Here's an example: it creates
|>a push button; activate it or wait for a timed AST to off 5 times and the
|>application ends.
It was my choice too. However I received mail from the original poster.
He is porting an application that uses COMMON event flags. It has been
discussed here before how to wait for flags in more than one cluster but
I can't find anything in my mail folders anymore about that. Anyone care to
jog my memory?
[example deleted]
|>
|> Dom Maddalone, dgm@cronus.colorado.edu
|> System Administrator, University Physicians, Inc., Denver
|>
--
-----------------------------------------------------+------------------+
Tim Llewellyn - OpenVMS, Soukous and Cricket Addict |Hey, and get wise |
Physicist Programmer, Bristol Uni Particle Physics. | to the sounds of |
HEPNET/SPAN 19716::TJL Internet tjl@siva.bris.ac.uk | Africa,seen. |
I speak for me and noone else OK (and I might even | Soukous Makossa |
change my mind sometimes!-) | Mbalax Rumba...|
-----------------------------------------------------+------------------+
Unix : don't y'all just love it ! It's what standards are all about :-).
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Waiting simultaneously on X event & VMS event flag?
@ 1994-07-20 21:07 Dom Maddalone
0 siblings, 0 replies; 7+ messages in thread
From: Dom Maddalone @ 1994-07-20 21:07 UTC (permalink / raw)
In article <Ct8pG6.1p0@info.bris.ac.uk>, tjl@siva.bris.ac.uk (Tim Llewellyn) writes:
>
>In article <1994Jul19.155807.1669@buckie.hsc.colorado.edu>,
>dgm@cronus.colorado.edu (Dom Maddalone) writes:
>
>|>
>|>In article <youngn-1807941655410001@158.234.17.99>, youngn@logica.co.uk
>|>(Nicholas Young) writes:
>|>
>|>>I have an Xt-based program running on OpenVMS/Alpha that needs to wait
>|>>simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
>|>>there an easy way to do this? Possibilities seem to be:
>|>>
>|>>1) Use XtAppAddInput (best, because portable). Can the alternative input
>|>>source be made to wait on event flags?
>
>It was my choice too. However I received mail from the original poster.
>He is porting an application that uses COMMON event flags. It has been
>discussed here before how to wait for flags in more than one cluster but
>I can't find anything in my mail folders anymore about that. Anyone care to
>jog my memory?
Hack: Have an AST procedure check for the common event flag; if not
set, re-queue itself for whatever time; if set, set the local
event flag (& die), which causes the Xevent, which kicks off
the user routine. [Then the user routine could clear it's
local event flag, clear the common event flag, and re-queue the
AST procedure.]
Dom Maddalone, dgm@cronus.colorado.edu
System Administrator, University Physicians, Inc., Denver
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Waiting simultaneously on X event & VMS event flag?
1994-07-18 16:55 Waiting simultaneously on X event & VMS event flag? Nicholas Young
1994-07-19 22:58 ` Dom Maddalone
@ 1994-07-21 13:35 ` Art Stine
1994-07-22 13:21 ` fisher
1994-07-27 9:57 ` dominique dierick
2 siblings, 1 reply; 7+ messages in thread
From: Art Stine @ 1994-07-21 13:35 UTC (permalink / raw)
In article <youngn-1807941655410001@158.234.17.99> youngn@logica.co.uk (Nicholas Young) writes:
Can anyone help, please ...
I have an Xt-based program running on OpenVMS/Alpha that needs to wait
simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
there an easy way to do this? Possibilities seem to be:
If you can live with using only the event flags in cluster 0, you can
do it easily with the existing event flag routines - get the EF that X is
using via ConnectionNumber (display) and just add it to the mask of
flags you want to wait for.
-art
visix software inc.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Waiting simultaneously on X event & VMS event flag?
1994-07-21 13:35 ` Art Stine
@ 1994-07-22 13:21 ` fisher
0 siblings, 0 replies; 7+ messages in thread
From: fisher @ 1994-07-22 13:21 UTC (permalink / raw)
In article <ABSTINE.94Jul21093540@hummer.visix.com>, abstine@visix.com (Art
Stine) writes:
|>In article <youngn-1807941655410001@158.234.17.99> youngn@logica.co.uk
(Nicholas Young) writes:
|>
|>
|> Can anyone help, please ...
|>
|> I have an Xt-based program running on OpenVMS/Alpha that needs to wait
|> simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
|> there an easy way to do this? Possibilities seem to be:
|>
|>If you can live with using only the event flags in cluster 0, you can
|>do it easily with the existing event flag routines - get the EF that X is
|>using via ConnectionNumber (display) and just add it to the mask of
|>flags you want to wait for.
Have you actually tried this on VMS? It works on Unix with a select(), but I'd
be surprised if it were reliable on VMS for several reasons:
1) Not all transport types use event flags, or at least not in the same way.
For example, I don't believe there is an event flag set for each data transfer
when using the shared-memory LOCAL transport.
2) Even real network-based transports don't necessarily get exactly 1 EF setting
per event (if I remember right, anyway).
3) Event flags are not unique, like file descriptors in Unix. You really need a
combination of the EF and an IOSB (for normal IOs anyway).
4) ConnectionNumber(dpy) is just that, a connection number. It is normally used
to index an array of per-connection information. In Unix, an FD works here, and
that is what is normally done. However in VMS, a separate EF is not used for
each display, so ConnectionNumber is consed up in another way. (Unless it has
changed since I stopped working on it...)
Anyway, if you can confine yourself to cluster 0, then you might as well use the
standard supported way of XtAddInput (which I guess changed to XtAppAddInput
when I was not looking).
Burns
(Former VMS DECwindows developer)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Waiting simultaneously on X event & VMS event flag?
1994-07-18 16:55 Waiting simultaneously on X event & VMS event flag? Nicholas Young
1994-07-19 22:58 ` Dom Maddalone
1994-07-21 13:35 ` Art Stine
@ 1994-07-27 9:57 ` dominique dierick
2 siblings, 0 replies; 7+ messages in thread
From: dominique dierick @ 1994-07-27 9:57 UTC (permalink / raw)
In article <youngn-1807941655410001@158.234.17.99>, youngn@logica.co.uk (Nicholas Young) writes:
Can anyone help, please ...
I have an Xt-based program running on OpenVMS/Alpha that needs to wait
simultaneously on X events and VMS event flags. [Don't ask why :-)] Is
there an easy way to do this? Possibilities seem to be:
1) Use XtAppAddInput (best, because portable). Can the alternative input
source be made to wait on event flags?
2) Go below the X level and use something else. Is XNextEvent implemented
using QIOs, and if so can I both use them to get X events and also to wait
on event flags? Or does X use some obscure VMS mechanism?
3) [Last resort] Write a separate app/thread that sits there waiting for
the event flag and dispatches some sort of alternative input to the Xt
loop (see (1)).
Or is there a better way that I've missed?
Advice, pointers or sample code gratefully appreciated. Mail preferred;
I'll post the results if there is any interest.
Thanks,
Nicholas.
--
Nicholas Young. Opinions expressed above are mine, not Logica's.
I am often away; please mail me if you wish to be sure I see articles.
"'Macbeth' is a play written by a man who, on this occasion at least, if he had the talent, ought to have written a fairy tale." - J.R.R.Tolkien.
> I have ( 5 years ago, still in my VMS days ;-) ) used option 1 ( XtAppAdd
> Input ) and it worked. Don't ask for details though, it's too long ago.
--
=============================================================
**** **** **** * ** **** * * ****
* * * * * ** * * * * * *
* * **** *** * ** **** **** * ****
* * * * * ** * * * * *
**** **** * * ** * * * * *
Dominique Dierick
Digital Equipment Corporation, Brussels
dierick@cygnusx1.bro.dec.com Phone : 32-2-729-75-48
dierick@brsux0.bro.dec.com
Only speaking for myself here, not for Digital ...
=============================================================
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1994-07-27 9:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-07-18 16:55 Waiting simultaneously on X event & VMS event flag? Nicholas Young
1994-07-19 22:58 ` Dom Maddalone
1994-07-20 13:00 ` Tim Llewellyn
1994-07-21 13:35 ` Art Stine
1994-07-22 13:21 ` fisher
1994-07-27 9:57 ` dominique dierick
-- strict thread matches above, loose matches on Subject: below --
1994-07-20 21:07 Dom Maddalone
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox