MIDAS
Loading...
Searching...
No Matches
odb_lock_test.cxx File Reference
#include <assert.h>
#include "midas.h"
#include "msystem.h"
Include dependency graph for odb_lock_test.cxx:

Go to the source code of this file.

Functions

void test1 (HNDLE hDB)
 
int thread1 (void *)
 
void test2 (HNDLE hDB)
 
int main (int argc, char *argv[])
 

Variables

HNDLE xhDB = -1
 
BOOL xThread1done = false
 

Function Documentation

◆ main()

int main ( int  argc,
char argv[] 
)

Definition at line 85 of file odb_lock_test.cxx.

86{
89 int status = 0;
90 char host_name[256];
91 char expt_name[256];
92 host_name[0] = 0;
93 expt_name[0] = 0;
94
96
98 assert(status == CM_SUCCESS);
99
100 HNDLE hDB;
102 assert(status == CM_SUCCESS);
103
105
106 test1(hDB);
107 test2(hDB);
108
110 assert(status == CM_SUCCESS);
111
112 return 0;
113}
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
Definition midas.cxx:3011
INT cm_connect_experiment1(const char *host_name, const char *default_exp_name, const char *client_name, void(*func)(char *), INT odb_size, DWORD watchdog_timeout)
Definition midas.cxx:2297
INT cm_disconnect_experiment(void)
Definition midas.cxx:2846
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
Definition midas.cxx:2134
INT cm_set_watchdog_params(BOOL call_watchdog, DWORD timeout)
Definition midas.cxx:3283
#define CM_SUCCESS
Definition midas.h:582
HNDLE hDB
main ODB handle
Definition mana.cxx:207
char host_name[HOST_NAME_LENGTH]
Definition mana.cxx:242
char expt_name[NAME_LENGTH]
Definition mevb.cxx:44
INT HNDLE
Definition midas.h:132
#define DEFAULT_ODB_SIZE
Definition midas.h:270
void test2(HNDLE hDB)
void test1(HNDLE hDB)
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ test1()

void test1 ( HNDLE  hDB)

Definition at line 14 of file odb_lock_test.cxx.

15{
16 printf("test1: test recursive ODB lock\n");
17 printf("lock1\n");
19 printf("lock2\n");
21 printf("lock3\n");
23 printf("sleep\n");
24 sleep(5);
25 printf("unlock3\n");
27 printf("unlock2\n");
29 printf("sleep\n");
30 sleep(5);
31 printf("unlock1\n");
33 printf("done.\n");
34}
INT db_lock_database(HNDLE hDB)
Definition odb.cxx:2455
INT db_unlock_database(HNDLE hDB)
Definition odb.cxx:2577
#define sleep(ms)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test2()

void test2 ( HNDLE  hDB)

Definition at line 56 of file odb_lock_test.cxx.

57{
58 //int timeout = db_set_lock_timeout(hDB, 0);
59 //db_set_lock_timeout(hDB, 10000);
60 printf("test2: test multithread locking\n");
61 printf("t0: lock1\n");
63 printf("t0: lock1 done\n");
64 xhDB = hDB;
66 printf("t0: sleep\n");
67 sleep(5);
68 printf("t0: unlock1\n");
70 printf("t0: lock2\n");
72 printf("t0: lock2 done\n");
73 printf("t0: unlock2\n");
75 printf("t0: unlock2 done\n");
76 printf("t0: waiting for thread1...\n");
77 while (!xThread1done) {
78 printf("t0: waiting\n");
79 sleep(1);
80 }
81 printf("t0: done.\n");
82 //db_set_lock_timeout(hDB, timeout);
83}
midas_thread_t ss_thread_create(INT(*thread_func)(void *), void *param)
Definition system.cxx:2310
int thread1(void *)
BOOL xThread1done
HNDLE xhDB
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thread1()

int thread1 ( void )

Definition at line 39 of file odb_lock_test.cxx.

40{
41 HNDLE hDB = xhDB;
42 printf("t1: thread started\n");
43 printf("t1: lock1\n");
45 printf("t1: lock1 done\n");
46 printf("t1: sleep\n");
47 sleep(5);
48 printf("t1: unlock1\n");
50 printf("t1: unlock1 done\n");
51 printf("t1: thread done\n");
53 return 0;
54}
#define TRUE
Definition midas.h:182
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ xhDB

HNDLE xhDB = -1

Definition at line 36 of file odb_lock_test.cxx.

◆ xThread1done

BOOL xThread1done = false

Definition at line 37 of file odb_lock_test.cxx.