E From:	CSBVAX::MRGATE!info-vax-relay@kl.sri.com@SMTP  7-JUN-1988 01:59  To:	ARISIA::EVERHARTA Subj:	Further Thoughts On Sharing Information Between Programs...     T Received: from linc.cis.upenn.edu by KL.SRI.COM with TCP; Mon 30 May 88 19:05:12-PDT2 Received: from XRT.UPENN.EDU by linc.cis.upenn.edu( 	id AA29822; Mon, 30 May 88 22:05:08 EDT% Posted-Date: Mon, 30 May 88 22:06 EDT 3 Message-Id: <8805310205.AA29822@linc.cis.upenn.edu>  Date: Mon, 30 May 88 22:06 EDT0 From: "Clayton, Paul D." <CLAYTON@xrt.upenn.edu>D Subject: Further Thoughts On Sharing Information Between Programs... To: INFO-VAX@KL.SRI.COM  X-Vms-To: @INFOVAX,CLAYTON  K In response to an appropiate rebuke for proposing a solution that required  H privledges to peform the sharing of data between the same process using . INSTALLed images, I offer ANOTHER alternative.  O There IS a feature of VMS called global sections that can contain anything the  P designer/coder wishes to segregate, and MAYBE share with someone else. There areO several versions of global sections that can be created through system service  K calls. They boil down to system, group global sections and process private  L sections and have secondary options, in some cases, of being permemant. The H 'permemant' option means that until a system reboot is performed or the L system service to delete the global section ($DGBLSC) is called the section N will remain in memory ready for another process to map to it. Note that these ; sections are NOT SHARED among processors in a VAXCluster!!!   O Needless to say the SYSTEM version of global sections requires privs (SYSGBL),  L and the permenant section also needs privs (PRMGBL).  Looking this through, K the ability to use group level sections that are not permenant is a viable  M option to share data among various users. The only remaining problem area is  O to insure that your UAF record has enough quotas (PGFLQUOTA among others), and  6 having the SAME GROUP UIC number to use this feature.   N One way is to specify a data file that you already have as being the input to N the $CRMPSC call with the appropiate switches and give it UNIQUE name. Beware O the 'Demand_zero' option as it will erase any existing data in the file if the  O file does contain any meaningful data. Other users will essentially invoke the  M same call to the system service with the same set of parameters and the same  O UNIQUE name. If everyone uses the same call, then the case of who is the FIRST  L one in is a don't care situation. The FIRST time caller will get the status ? of SS$_CREATED while the follow-up people will get SS$_NORMAL.    N I have used this method to share data between programs written in FORTRAN and 5 after solving some initial problems had no problems.    J The problems and the workarounds I have found are listed below. Note that O these are with FORTRAN overtones, so the PASCAL people will have to convert to   what is appropiate.   N 1. The EASIEST way to handle the ALIGNMENT of the global section is to put it N on a FULL PAGE boundary, compliments of the LINKer. This serves two purposes. O The first being the mapping is slightly better for this sort of thing when the  O start of the section is on a full page boundary. The second is that it is very  I easy then to have the section map to a disk file and keep the '512 byte'  I outlook when the debugging gets tough and the dumps of the disk file are  O staring you in the face. This is done through the LINKer in the '.OPT' file by  O defining the characteristics of the Program Sections (PSECTS) that you need to  N accomplish this. To also ease the problem here do yourself two favors. First, K only have one common per global section and give it a unique name. Second,  P create ANOTHER COMMON with the same unique name but having a suffix of '_AAAAA'.M There need only be a single variable in this second common and it need never  H be referenced in the program. It is serving a LINKing problem only. The < typical line in the .OPT file would look like the following.  ( PSECT_ATTR=XXX,PAGE,NOEXE,RD,WRT,GBL,SHR. PSECT_ATTR=XXX_AAAAA,PAGE,NOEXE,RD,WRT,GBL,SHR  N where XXX is the name of the PSECT containing the COMMON that is to be shared M among the various users. By specifging the .OPT file you are OVER-RIDING the  6 compiler generated specifications for these sections.   N The question to ask now is WHY create a SECOND common with the funky suffix?? K The answer lies in the way the LINKer does its thing. All the names of the  K PSECTS are gathered together and placed in alpha order, by default, so the  L first thing that the '_AAAAA' section does is IMMEDIALTELY FOLLOW the PSECT M containing the common you want to share. The call to the $CRMPSC service can  M use as the address reference points the first variable in the 'XXX' PSECT as  M the starting address and the first variable in the 'XXX_AAAAA' as the ending  K address. This puts EVERYTHING on 512 byte incrementals and its all set for  F mapping to a disk file. The '_AAAAA' section also provides a means to I eliminate a portion of a previously mapped OR non-shared section of your  I program from being OVER-WRITTEN as a result of the mapping of the global  O section to a disk file. This latter was a problem that I spent the better part  3 of a week seeking the cause, then the solution for.   N 2. A VERY good reading of the LINKer manual is in order for anyone interested K in doing this type of thing. The information is well layed out and clearly  M detailed, although the first, and maybe the second times will be with clouds  	 overhead.   G Hope this is helpful in the effort to share data between programs, and  O suffices as penance for my earlier suggestion of other means to share data. :-)    pdc    Paul D. Clayton # Address - CLAYTON%XRT@CIS.UPENN.EDU   M Disclaimer:  All thoughts and statements here are my own and NOT those of my  H employer, and are also not based on, or contain, restricted information.  