Click here to Skip to main content
15,893,381 members
Articles / Programming Languages / C++

Shared and Exclusive lock control

Rate me:
Please Sign up or sign in to vote.
3.05/5 (7 votes)
31 Aug 20042 min read 44.3K   629   11  
C++ class for shared and exclusive lock control.
tlockter_readme.txt

This file describes the TLOCKER test program.

TLOCKER.EXE is a Win32 console application that exercises the Locker class.

Double-click on it, and watch the execution.
The test log is placed in TLOCKER.TXT in the current directory.
A progress commentary is displayed on the console.

Test description:

Group 1:

Tests all Locker functions for LNAME > 64 bytes.
    All 4 tests should return RC=-1.

Group 2:

Runs for 20 seconds.

There are 2 "data bases"  A & B
Their ADDRESSes are used as the lock name.

6 threads are started, passing a structure containing:
   Locker class
   Thread number
   Lock type (FALSE=read only, TRUE=update)
   Pointer to Data Base address
     (Even numbered threads get B, Odd numbered threads get data base A)

Threads 2 and 5 update their data base using exclusive locks.  The data base
    value field is incremented on each pass.
Threads 0, 1, 3, and 4 display the current data base value.

There is a 10ms timer delay on all threads except for ODD/update threads, which wait for
   500ms.  This unbalances the execution against the two data bases, making their respective
   values diverge.  This simulates a longer code path for one data base update.

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
Application and systems programmer since 1972.
Mostly mainframe programming - Assembler, PL/X.
Products: IBM: DFSMSHSM, Candle Corp: Omegamon (IMS and MVS), PKWARE: SecureZIP


Dabble in Windows and Linux at home - C++ and Intel Assembler.

Comments and Discussions