Click here to Skip to main content
12,831,317 members (52,777 online)
Click here to Skip to main content


11 bookmarked
Posted 25 Aug 2004

Shared and Exclusive lock control

, 31 Aug 2004
C++ class for shared and exclusive lock control.

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.


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


About the Author

Charles Bargar
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.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 1 Sep 2004
Article Copyright 2004 by Charles Bargar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid