include/Process.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
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]; //list of thread specific transactions
00054 
00055     Mutex *want_;  //single mutex which we are waiting for.
00056 
00057     Mutex *has_[MAX_MUTEX_PER_THREAD];   //list of mutexes held
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     //ThreadInfo *thrInfo;
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

Generated on Mon Jun 9 22:37:14 2008 for csql by  doxygen 1.4.7