changing global prepare mutex to process level mutex
[csql.git] / include / Process.h
blobbb9a8c1f3efc9dcfb9145897024c9c7333821581
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef PROCESS_H
17 #define PROCESS_H
19 #include<os.h>
20 #include<ErrorType.h>
21 #include<Mutex.h>
22 #include<Transaction.h>
23 #include<Util.h>
25 class ProcInfo
27 public:
29 pid_t pid_;
31 int numThreads_;
35 struct ThreadTrans{
36 pid_t pid_;
37 pthread_t thrid_;
38 Transaction *trans_;
39 ThreadTrans() { pid_ =0; thrid_ =0; trans_ = NULL; }
40 void init() { pid_ =0; thrid_ =0; trans_ = NULL; }
41 void print();
45 class ThreadInfo
47 public:
49 pid_t pid_;
51 pthread_t thrid_;
53 ThreadTrans thrTrans_; //list of thread specific transactions
55 Mutex *want_; //single mutex which we are waiting for.
57 Mutex *has_[MAX_MUTEX_PER_THREAD]; //list of mutexes held
58 void init();
59 void print();
62 class ProcessManager
64 public:
65 static int noThreads;
66 static Mutex mutex;
67 static Mutex prepareMutex;
68 static caddr_t sysAddr;
69 static caddr_t usrAddr;
70 static Database *systemDatabase;
71 static List hasLockList;
73 //ThreadInfo *thrInfo;
74 ProcessManager() { }
75 DbRetVal registerThread();
76 DbRetVal deregisterThread(int slot);
77 static DbRetVal addMutex(Mutex *mutex, int pslot);
78 static DbRetVal removeMutex(Mutex *mutex, int pslot);
80 static DbRetVal setThreadTransaction(Transaction *trans, int pslot);
81 static Transaction* getThreadTransaction(int pslot);
83 static Transaction** getThreadTransAddr(int pslot);
85 void printUsageStatistics();
86 void printDebugInfo();
87 int procSlot;
88 int getProcSlot() { return procSlot; }
89 bool isAnyOneRegistered();
92 #endif