- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- timeout for sys$waitfr
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 08:28 AM
тАО12-06-2010 08:28 AM
I just looking to something with event flags technique.
There are a couple calls for wait the flags
SYS$WAITFR SYS$WFLAND SYS$WFLOR
all will wait infinity time until the flag(s) have been set.
But I wish to wait only a fixed time period.
This is code example:
/*---------------------------*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "errchk.h"
/******************************************************************************/
static void ast_routine (unsigned int efn) {
static unsigned long int r0_status;
r0_status = sys$setef (efn);
errchk_sig (r0_status);
}
/******************************************************************************/
int main (void) {
static IOSB iosb;
static unsigned long int r0_status;
static unsigned int pid;
static unsigned int group;
static unsigned int member;
static char username[12];
static unsigned short int username_len;
static unsigned int efn;
static ILE3 jpiitms[] = { 4, JPI$_PID, &pid, NULL,
4, JPI$_GRP, &group, NULL,
4, JPI$_MEM, &member, NULL,
12, JPI$_USERNAME, username, &username_len,
0, 0, NULL, NULL };
r0_status = lib$get_ef (&efn);
r0_status = sys$getjpi (EFN$C_ENF,
0,
0,
jpiitms,
&iosb,
ast_routine,
efn);
errchk_sig (r0_status);
/*
** Wait for the event flag to be set by the AST.
*/
r0_status = sys$waitfr (efn);
errchk_sig (r0_status);
r0_status = lib$free_ef (&efn);
errchk_sig (r0_status);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 08:29 AM
тАО12-06-2010 08:29 AM
Re: timeout for sys$waitfr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 09:01 AM
тАО12-06-2010 09:01 AM
SolutionWRT your sample code, it appears that your ast serves no purpose, since your ast_routine simply sets the event flag, the call to SYS$GETJPI is coded to set the event flag anyway. Personally, I would get rid of the ast routine.
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 09:23 AM
тАО12-06-2010 09:23 AM
Re: timeout for sys$waitfr
add a sys$setimr call with an AST in which you set efn. Also add a sys$cantim in your ast_routine to remove the outstanding timer event in case the sys$getjpi finishes first to prevent firing the timer AST later on.
You may pass a longword[2] array as AST parameter to your ast_routine which contains the event flag number and the reqid from the sys$setimr call so you can cancel the timer event.
Specify EFN$C_ENF (=no event flag) in the sys$setimr call because you only use the AST method for triggering.
/Guenther
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 11:57 AM
тАО12-06-2010 11:57 AM
Re: timeout for sys$waitfr
There are several ways this question could go. Interestingly, all of which involve expunging the event flags for all but the simplest use.
Are you looking specifically for the PID, username and group? If so, expunge the event flags...
Are you looking to learn AST programming here? (If so, then expunge the event flags, and replace that ASTPRM with a malloc'd context block structure, and pass the R0 value and the IOSB that way.)
Might sys$getjpiw() work better here? If so, expunge the event flags...
Might sys$synch work better here? Expunge the event flags...
Are you looking to continue trying to pound the hack that is an event flag into something more functional? Or are you open to alternatives? In all bluntness, event flags are a massive hack and something best avoided for all but the simplest cases, and best expunged.
Oh, and remember to expunge the event flags. Did I mention I'm not fond of event flags? Oh, and event flags WILL cause you headaches in all but the simplest cases.
If it's not clear, event flags are not something that I'd suggest using in all but the simplest of cases.
There are some coding errors here, not the least of which is the mishandling of the static values; that r0_status value gets reused, which well could mean the tests are going to behave oddly. (There's an AST here that can hit between the end and the return from the $getjpi and the immediately-subsequent errchk_sig() call here, and that AST overwrites r0_status.)
Don't forget to get rid of those event flags, too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 12:36 PM
тАО12-06-2010 12:36 PM
Re: timeout for sys$waitfr
I don't see such a coding error. r0_status has local scope and global duration, that doesn't make r0_status in main accessible to ast_routine. If static is necessary, is a good style and results in good performance is a different question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 01:09 PM
тАО12-06-2010 01:09 PM
Re: timeout for sys$waitfr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 03:52 PM
тАО12-06-2010 03:52 PM
Re: timeout for sys$waitfr
For the most part, I agree with Hoff. Event flags are a concept that is useful in fairly simple code, which functionally almost always means "get rid of them".
The example of using an AST to set an event flag is an echo from a poorly chosen example long ago in the RSX-11 Executive manual. When I started on RSX, that example never made sense to me. It seemed pointless. Reviewing the source listings, I found out how ASTs were really used in the code base, and the concept made far more sense.
If you are doing GETJPI against the current process, the timeout is not a real concern. If you are inquiring about another process, the way to do it is by declaring both a GETJPI and a TIMER request, and then doing what is appropriate if the TIMER fires first. One must remember that ASTs are FIFO and non-premptable WITHIN A PROCESS. One must also consider the possibility that the TIMER request will fire while the AST for the GETJPI is running. A common error in these situations is one or more dangling pointers.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 04:00 PM
тАО12-06-2010 04:00 PM
Re: timeout for sys$waitfr
I'm with Hoff. Event flags are very limited and have all kinds of nasty potential timing issues. They made a bit more sense long ago in the days of uniprocessors (but not much!). These days I usually stick with EFN$C_ENF and try to forget that event flags exist.
For asynchronous requests that don't have timeout options, you can usually implement your own using "crossed ASTs". The basic principle is
1) set a timer AST, which cancels the event request and issues a $WAKE,
2) make the request , specifying an AST which cancels the timer and issues a $WAKE
3) $HIBER (waiting for event or timer) work out what happened by looking at the IOSB.
This works for most things, BUT realise that $GETJPI has no cancel mechanism. So, if you timeout, you leave resources pending. There's a potential to deplete resources, like ASTLM, especially with a short timeout. You also need to be VERY careful with reusing variables in subsequent asynch calls. For example, you can't reuse the IOSB for calling another $GETJPI before the previous one has completed.
As John McL says, a timeout $GETJPI against yourself is extremely unlikely, but if you're scanning multiple processes in a large cluster, you might get into trouble.
If you insist on using event flags, you can do what you want by scheduling a timer to set the EFN you're waiting for, or use a second flag and $WFLOR the pair of them. You may also want to consider allocating yourself an EFN longer term. LIB$GET_EF and LIB$FREE_EF are fairly cheap, but if you're concerned enough about time to worry about $GETJPI...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2010 06:16 PM
тАО12-06-2010 06:16 PM
Re: timeout for sys$waitfr
If it was just about sys$getjpi...hello... there's a sys$getjpi"W", which btw. could go across the cluster and could be delayed up-to RECNXINTERVAL.
Cheers,
Guenther