25 #include "pedigree/kernel/Atomic.h" 26 #include "pedigree/kernel/Spinlock.h" 27 #include "pedigree/kernel/compiler.h" 28 #include "pedigree/kernel/process/Semaphore.h" 29 #include "pedigree/kernel/process/Thread.h" 30 #include "pedigree/kernel/processor/types.h" 31 #include "pedigree/kernel/time/Time.h" 32 #include "pedigree/kernel/utilities/List.h" 33 #include "pedigree/kernel/utilities/MemoryAllocator.h" 34 #include "pedigree/kernel/utilities/StaticString.h" 35 #include "pedigree/kernel/utilities/Vector.h" 36 #include "pedigree/kernel/utilities/new" 38 #include "pedigree/kernel/Subsystem.h" 98 size_t addThread(
Thread *pThread);
100 void removeThread(
Thread *pThread);
103 size_t getNumThreads();
105 Thread *getThread(
size_t n);
122 return m_pAddressSpace;
180 return m_SpaceAllocator;
185 return m_DynamicSpaceAllocator;
202 return m_pEffectiveUser;
207 m_pEffectiveUser = pUser;
224 return m_pEffectiveGroup;
226 void setEffectiveGroup(
Group *pGroup)
228 m_pEffectiveGroup = pGroup;
233 virtual int64_t getUserId()
const;
234 virtual int64_t getGroupId()
const;
235 virtual int64_t getEffectiveUserId()
const;
236 virtual int64_t getEffectiveGroupId()
const;
241 m_pDynamicLinker = pDl;
245 return m_pDynamicLinker;
250 m_pSubsystem = pSubsystem;
266 size_t waiterCount()
const;
270 bool bRet = m_bUnreportedSuspend;
271 m_bUnreportedSuspend =
false;
276 bool bRet = m_bUnreportedResume;
277 m_bUnreportedResume =
false;
286 void markTerminating()
288 m_State = Terminating;
291 void trackHeap(ssize_t nBytes)
293 m_Metadata.heapUsage += nBytes;
296 void trackPages(ssize_t nVirtual, ssize_t nPhysical, ssize_t nShared)
298 m_Metadata.virtualPages += nVirtual;
299 m_Metadata.physicalPages += nPhysical;
300 m_Metadata.sharedPages += nShared;
305 m_Metadata.virtualPages = 0;
306 m_Metadata.physicalPages = 0;
307 m_Metadata.sharedPages = 0;
308 m_Metadata.startTime = Time::getTimeNanoseconds();
319 Time::Timestamp now = Time::getTimeNanoseconds();
322 m_LastUserspaceEntry = now;
326 m_LastKernelEntry = now;
338 Time::Timestamp now = Time::getTimeNanoseconds();
341 Time::Timestamp diff = now - m_LastUserspaceEntry;
342 m_LastUserspaceEntry = now;
343 m_Metadata.userTime += diff;
345 reportTimesUpdated(diff, 0);
349 Time::Timestamp diff = now - m_LastKernelEntry;
350 m_LastKernelEntry = now;
351 m_Metadata.kernelTime += diff;
353 reportTimesUpdated(0, diff);
360 return m_Metadata.userTime;
362 Time::Timestamp getKernelTime()
const 364 return m_Metadata.kernelTime;
366 Time::Timestamp getStartTime()
const 368 return m_Metadata.startTime;
374 return m_Metadata.heapUsage;
376 ssize_t getVirtualPageCount()
const 378 return m_Metadata.virtualPages;
380 ssize_t getPhysicalPageCount()
const 382 return m_Metadata.physicalPages;
384 ssize_t getSharedPageCount()
const 386 return m_Metadata.sharedPages;
407 return m_bSharedAddressSpace;
417 static void setInit(
Process *pProcess);
515 void notifyWaiters();
521 : virtualPages(0), physicalPages(0), sharedPages(0), userTime(0),
522 kernelTime(0), startTime(0)
Group * getEffectiveGroup() const
bool m_bUnreportedSuspend
virtual void processTerminated()
List< Semaphore * > m_Waiters
ssize_t getHeapUsage() const
Time::Timestamp m_LastKernelEntry
File * getRootFile() const
bool m_bSharedAddressSpace
bool hasSharedAddressSpace() const
MemoryAllocator m_DynamicSpaceAllocator
VirtualAddressSpace * m_pAddressSpace
Time::Timestamp m_LastUserspaceEntry
void setEffectiveUser(User *pUser)
Vector< Thread * > m_Threads
Atomic< size_t > m_NextTid
MemoryAllocator & getDynamicSpaceAllocator()
Time::Timestamp getUserTime() const
Group * m_pEffectiveGroup
void setExitStatus(int code)
void recordTime(bool bUserspace)
void setRootFile(File *pFile)
static Process * m_pInitProcess
DynamicLinker * m_pDynamicLinker
virtual void reportTimesUpdated(Time::Timestamp user, Time::Timestamp system)
VirtualAddressSpace * getAddressSpace()
LargeStaticString & description()
virtual ProcessType getType()
MemoryAllocator m_SpaceAllocator
void trackTime(bool bUserspace)
void setUser(User *pUser)
User * getEffectiveUser() const
void setGroup(Group *pGroup)
Thread & operator=(const Thread &)
virtual void setProcess(Process *p)
Thread::Status m_BeforeSuspendState
MemoryAllocator & getSpaceAllocator()