submitting patch from enterprise version
[csql.git] / include / Process.h
blobc28fc3476be97e9dfb868b6312b4f4dee5a78516
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_[MAX_THREADS_PER_PROCESS]; //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 Database;
64 class ProcessManager
66 public:
67 static int noThreads;
68 static Mutex mutex;
69 static caddr_t sysAddr;
70 static caddr_t usrAddr;
71 static Database *systemDatabase;
72 static List hasLockList;
74 //ThreadInfo *thrInfo;
75 ProcessManager() { }
76 DbRetVal registerThread();
77 DbRetVal deregisterThread(int slot);
78 static DbRetVal addMutex(Mutex *mutex, int pslot);
79 static DbRetVal removeMutex(Mutex *mutex, int pslot);
81 static DbRetVal setThreadTransaction(Transaction *trans, int pslot);
82 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