Operating System - OpenVMS
1753328 Members
5030 Online
108792 Solutions
New Discussion юеВ

Emulating locks created by a BASIC program in C/C++

 
SOLVED
Go to solution
Ben Armstrong
Regular Advisor

Emulating locks created by a BASIC program in C/C++

Well, it's time to get to the crux of the matter. We have several hundred programs, each statically compiled at various dates with no chance of recompiling them all without opening a whole can of worms. Some of the key routines managing the access to the fixed-length 512 byte record files that they share are still written in BASIC because we have not figured out how to make compatible locks in C++.

So my question is, how do I emulate the locks that BASIC makes in C or C++? I have attached a test program to reproduce the kind of access performed by our BASIC routines.

I remember trying to make this work many years ago for a different project using sys$qio + sys$enq and failed. My hazy recollection is that the locks didn't match those created by BASIC, so the experiment failed. I'm anxious not to make the same mistake this time.

Thanks,
Ben
3 REPLIES 3
Robert Gezelter
Honored Contributor
Solution

Re: Emulating locks created by a BASIC program in C/C++

Ben,

The locks DO NOT depend on the language. If you are seeing "incompatible" locking, then the two implementations are accessing the files differently.

Using SYS$QIO and SYS$ENQ is most definitely NOT the way to achieve the desired interoperable result.

The desired result will be achieved by using the RMS libraries to access the file. RMS can be invoked implicitly through the C/C++ runtime (which can be cumbersome for other than straight sequential files), or it can be invoked directly, with all of the facilities being fully available.

I am on a break between meetings, so I do not have a chance to go digging through the BASIC documentation. What is needed is to look up and analyze the information about the file organization (as shown in the attached sources) and do the accesses in the same way. It will work.

I have to get ready for my meeting now, if I have been unclear, or can be of additional assistance, please let me know.

- Bob Gezelter, http://www.rlgsc.com
Hein van den Heuvel
Honored Contributor

Re: Emulating locks created by a BASIC program in C/C++

"organization virtual" ?! Yuck!

Anyway, those are simply RMS Fixed Length record files with RMS Record access services: SYS$GET, SYS$PUT (with RAB$V_UIF... double yuck)

>> So my question is, how do I emulate the locks that BASIC makes in C or C++? I


You don't emulate.
You just use direct calls to RMS to access the file/record.

SYS$OPEN... SYS$GET... SYS$PUT.

No ifs, else, or buts about it.

(I'll be happy to consult on details as needed :-)

Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting


Ben Armstrong
Regular Advisor

Re: Emulating locks created by a BASIC program in C/C++

Thanks for the clarification. As I said, it *was* a different project with different goals in mind (qio was a requirement for that project,) and it was many years ago. I wasn't even thinking of trying the same thing today. That being said, the memory of that earlier failure was making me feel a bit leery of tackling locks again.

In any event, I think I may have already answered my own question using the OpenVMS Freeware 'findlocks' utility and the test program supplied by David Jones as a response to my earlier inquiry:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1153251

If I run test.bas to lock a block in block.tmp, I see it the lock for vbn=1, id=0. Then I run David's bio_test.c and see it block on the lock until I press Enter to release it. Success!

So I'm feeling much better about proceeding now. Many thanks to everyone who has helped bring me this far.

Ben