signalmanager.h

Go to the documentation of this file.
00001 
00021 #ifndef SIGNALMANAGER_H
00022 #define SIGNALMANAGER_H
00023 
00024 #include <stdio.h>
00025 #include <linux/types.h>
00026 #include <vector>
00027 #include <time.h>
00028 #include <pthread.h>
00029 #include <assert.h>
00030 #include "buffer.h"
00031 #include "signals.h"
00032 
00033 using namespace std;
00034 
00035 namespace SMP{
00036 
00038 class SMPKernel;
00039 
00043 class SMPSignalManager
00044 {
00045 private:
00046     //SMPKernel *kernel;
00047 
00050     static int *interval; 
00052     vector<int> sig_fid;
00054     vector<pthread_t> sig_tid;
00056     static void *monitor_thread(void *arg);
00057 
00058 public:
00060     SMPSignalManager(SMPKernel *k);
00062     ~SMPSignalManager();
00063 
00071     void register_thread(int fid, pthread_t tid);
00072 
00075     void start();
00077     void stop(bool wait_handler);
00079     void clear();
00080     
00081     //user functions...
00082 
00084     void monitor(int id);
00086     void signal(int id);
00087 
00089     int get_thread_id(int fid);
00091     inline int get_filter_id(int id);
00093     inline void set_timeout_f(int fid, int ms);
00095     inline int get_timeout_f(int fid);
00097     inline static int get_timeout(int id);
00098 };
00099 
00100 
00101 int SMPSignalManager::get_filter_id(int id)
00102 {
00103     assert(id >= 0);
00104     return sig_fid[id];
00105 }
00106 
00107 void SMPSignalManager::set_timeout_f(int fid, int ms)
00108 {
00109     assert(fid >= 0);
00110     int id = get_thread_id(fid);
00111     interval[id] = ms;
00112 }
00113 
00114 int SMPSignalManager::get_timeout_f(int fid)
00115 {
00116     assert(fid >= 0);
00117     int id = get_thread_id(fid);
00118     return interval[id];
00119 }
00120 
00121 int SMPSignalManager::get_timeout(int id)
00122 {
00123     assert(id >= 0);
00124     return interval[id];
00125 }
00126 
00127 } //end namespace
00128 #endif

Generated on Fri Aug 31 15:41:42 2007 for SCREAMLinuxMiddleware(SLIM) by  doxygen 1.5.1