00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef PROCESS_H
00017 #define PROCESS_H
00018
00019 #include<os.h>
00020 #include<ErrorType.h>
00021 #include<Mutex.h>
00022 #include<Transaction.h>
00023 #include<Util.h>
00024
00025 class ProcInfo
00026 {
00027 public:
00028
00029 pid_t pid_;
00030
00031 int numThreads_;
00032
00033 };
00034
00035 struct ThreadTrans{
00036 pid_t pid_;
00037 pthread_t thrid_;
00038 Transaction *trans_;
00039 ThreadTrans() { pid_ =0; thrid_ =0; trans_ = NULL; }
00040 void init() { pid_ =0; thrid_ =0; trans_ = NULL; }
00041 void print();
00042 };
00043
00044
00045 class ThreadInfo
00046 {
00047 public:
00048
00049 pid_t pid_;
00050
00051 pthread_t thrid_;
00052
00053 ThreadTrans thrTrans_[MAX_THREADS_PER_PROCESS];
00054
00055 Mutex *want_;
00056
00057 Mutex *has_[MAX_MUTEX_PER_THREAD];
00058 void init();
00059 void print();
00060
00061 };
00062 class Database;
00063
00064 class ProcessManager
00065 {
00066 public:
00067 static int noThreads;
00068 static Mutex mutex;
00069 static caddr_t sysAddr;
00070 static caddr_t usrAddr;
00071 static Database *systemDatabase;
00072 static List hasLockList;
00073
00074
00075 ProcessManager() { }
00076 DbRetVal registerThread();
00077 DbRetVal deregisterThread(int slot);
00078 static DbRetVal addMutex(Mutex *mutex, int pslot);
00079 static DbRetVal removeMutex(Mutex *mutex, int pslot);
00080
00081 static DbRetVal setThreadTransaction(Transaction *trans, int pslot);
00082 static Transaction* getThreadTransaction(int pslot);
00083 static Transaction** getThreadTransAddr(int pslot);
00084
00085 void printUsageStatistics();
00086 void printDebugInfo();
00087 int procSlot;
00088 int getProcSlot() { return procSlot; }
00089 bool isAnyOneRegistered();
00090 };
00091
00092 #endif