--- q_a/samples/readwrit/database.c 2018/08/09 18:29:19 1.1.1.1 +++ q_a/samples/readwrit/database.c 2018/08/09 18:29:32 1.1.1.2 @@ -1,3 +1,47 @@ +/****************************************************************************\ +** ** +** Microsoft Developer Support ** +** Copyright (c) 1992 Microsoft Corporation ** +** ** +** MODULE: DataBase ** +** ** +** ** +** PURPOSE: Demonstrates the basic concepts of one of the classical ** +** synchronous problems. A derivative of the Reader/Writer ** +** problem. In which one must allow access to each without ** +** jeopardizing the Database. ** +** ** +** INTERNAL FUNCTIONS: ** +** ** +** InitializeDataBase ** +** CloseDataBase ** +** InitializeSubsystem ** +** InitApp ** +** CleanupSubsystem ** +** CleanupApp ** +** TestInitExitPoint ** +** ErrorMsg ** +** DebugMsg ** +** ** +** ** +** EXPORTED FUNCTIONS ** +** ** +** ReadDataBase ** +** WriteDataBase ** +** ** +** ** +** COMMENTS: ** +** ** +** This also demonstrates how to have both global shared data ** +** instance data. What I've done is named the shared section ** +** with the #pragma data_seg( SEGNAME, "" ) statement and ** +** referenced this in the DEF file as READ/WRITE/SHARED. ** +** ** +\***************************************************************************/ + + + + #define STRICT #define NOMINMAX #include @@ -25,7 +69,21 @@ typedef HANDLE HEVENT ; /*global Variables */ + + +/* Put gUserCount in a GLOBAL section. This is because first time + * initialization is handled differently than others + */ + +#pragma data_seg("MYSEG", "") + int gUserCount = 0 ; + +#pragma data_seg(".data", "") + + + + HMUTEX ghMutex ; HSEM ghSemaphore ; HEVENT ghReadEvent1, ghReadEvent2, ghWriteEvent1, ghWriteEvent2 ; @@ -66,49 +124,6 @@ VOID DebugMsg ( PSZ psz ) ; -/***** Public functions *****/ - -BOOL APIENTRY ReadDataBase ( PSZ, PSZ ) ; -BOOL APIENTRY WriteDataBase ( PSZ, PSZ ) ; - - - - - -/***************************************************************************\ -** ** -** PROGRAM: DataBase ** -** ** -** PURPOSE: Demonstrates the basic concepts of one of the classical ** -** synchronous problems. A derivative of the Reader/Writer ** -** problem. In which one must allow access to each without ** -** jeopardizing the Database. ** -** ** -** INTERNAL FUNCTIONS: ** -** ** -** InitializeDataBase ** -** CloseDataBase ** -** InitializeSubsystem ** -** InitApp ** -** CleanupSubsystem ** -** CleanupApp ** -** TestInitExitPoint ** -** ErrorMsg ** -** DebugMsg ** -** ** -** ** -** EXPORTED FUNCTIONS ** -** ** -** ReadDataBase ** -** WriteDataBase ** -** ** -** ** -** COMMENTS: ** -** ** -** Currently this ** -** ** -\***************************************************************************/ - /***************************************************************************\ @@ -144,7 +159,7 @@ VOID ErrorMsg ( PSZ psz ) \****************************************************************************/ -VOID APIENTRY DebugMsg ( PSZ psz ) +VOID DebugMsg ( PSZ psz ) { printf ( psz ) ; } @@ -185,7 +200,6 @@ BOOL APIENTRY DLLInitExitPoint ( HANDLE gUserCount++ ; - printf ( "\nInitializing subsystem" ) ; printf ( "\nNumber of clients currently using this are %d\n", gUserCount ) ; if ( gUserCount == 1 )