Process.cc
Go to the documentation of this file.00001 #include "Process.h"
00002 #include "SharedGlobals.h"
00003 #include "Sound/SoundManager.h"
00004 #include "IPC/SharedObject.h"
00005 #include "Shared/MarkScope.h"
00006 #include "Shared/debuget.h"
00007 #include <unistd.h>
00008
00009 using namespace std;
00010
00011 Process* Process::procs[ProcessID::NumProcesses];
00012
00013 Process::Process(ProcessID::ProcessID_t pid, const std::string& pname) {
00014 ProcessID::setID(pid);
00015 procs[pid]=this;
00016 globals->pids[ProcessID::getID()]=getpid();
00017 strncpy(globals->processNames[ProcessID::getID()],pname.c_str(),SharedGlobals::MAX_PROCESS_NAME_LEN);
00018 }
00019
00020 Process::~Process() {
00021 procs[ProcessID::getID()]=NULL;
00022 }
00023
00024 void Process::run() {
00025 globals->waitShutdown();
00026 }
00027
00028 void Process::statusReport(std::ostream& os) {
00029 os << getName() << " (" << ProcessID::getID() << ") Attached Regions -----------" << endl;
00030 RCRegion::attachedRegions_t::const_iterator it=RCRegion::attachedBegin(true);
00031 for(; it!=RCRegion::attachedEnd(); RCRegion::attachedAdvance(it)) {
00032
00033 unsigned int lref=(it->second->NumberOfLocalReference()-1);
00034 unsigned int ref=(it->second->NumberOfReference()-1);
00035 os << '\t' << setw(16) << left << it->first << setw(8) << right << it->second->Size() << " bytes" << setw(8) << lref<<'/'<<ref << " references" << endl;
00036 }
00037 os << '\t' << setw(16) << left << "Next RCRegion ID: " << setw(8) << right << RCRegion::getNextKey() << endl;
00038 os << '\t' << setw(16) << left << "Next ShdObj ID: " << setw(8) << right << SharedObjectBase::getNextKey() << endl;
00039 if(sndman!=NULL)
00040 os << '\t' << setw(16) << left << "Next SndRgn ID: " << setw(8) << right << sndman->getNextKey() << endl;
00041 }
00042
00043 bool Process::statusReport(RCRegion* msg) {
00044 Process* cur=Process::getCurrent();
00045 ASSERTRETVAL(cur!=NULL,"statusReport, but NULL process!",true);
00046 if(strncasecmp(msg->Base(),getName(),msg->Size())==0 || strncasecmp(msg->Base(),"all",msg->Size())==0) {
00047 MarkScope l(globals->lock);
00048 cur->statusReport(cout);
00049 cout << endl;
00050 }
00051 return true;
00052 }
00053
00054
00055
00056
00057
00058