22 #include "pedigree/kernel/process/Process.h" 23 #include "modules/system/users/Group.h" 24 #include "modules/system/users/User.h" 25 #include "pedigree/kernel/Atomic.h" 26 #include "pedigree/kernel/LockGuard.h" 27 #include "pedigree/kernel/Log.h" 28 #include "pedigree/kernel/Spinlock.h" 29 #include "pedigree/kernel/Subsystem.h" 30 #include "pedigree/kernel/process/PerProcessorScheduler.h" 31 #include "pedigree/kernel/process/Scheduler.h" 32 #include "pedigree/kernel/process/Semaphore.h" 33 #include "pedigree/kernel/process/Thread.h" 34 #include "pedigree/kernel/processor/Processor.h" 35 #include "pedigree/kernel/processor/ProcessorInformation.h" 36 #include "pedigree/kernel/processor/VirtualAddressSpace.h" 37 #include "pedigree/kernel/processor/types.h" 38 #include "pedigree/kernel/time/Time.h" 39 #include "pedigree/kernel/utilities/Iterator.h" 40 #include "pedigree/kernel/utilities/List.h" 41 #include "pedigree/kernel/utilities/MemoryAllocator.h" 42 #include "pedigree/kernel/utilities/StaticString.h" 43 #include "pedigree/kernel/utilities/Vector.h" 44 #include "pedigree/kernel/utilities/ZombieQueue.h" 45 #include "pedigree/kernel/utilities/utility.h" 50 : m_Threads(), m_NextTid(0), m_Id(0), str(), m_pParent(0),
52 m_ExitStatus(0), m_Cwd(0), m_Ctty(0), m_SpaceAllocator(false),
53 m_DynamicSpaceAllocator(false), m_pUser(0), m_pGroup(0),
54 m_pEffectiveUser(0), m_pEffectiveGroup(0), m_pDynamicLinker(0),
55 m_pSubsystem(0), m_Waiters(), m_bUnreportedSuspend(false),
56 m_bUnreportedResume(false), m_State(Active),
57 m_BeforeSuspendState(
Thread::Ready), m_Lock(false), m_Metadata(),
58 m_LastKernelEntry(0), m_LastUserspaceEntry(0), m_pRootFile(0),
59 m_bSharedAddressSpace(false), m_DeadThreads(0)
62 m_Metadata.
startTime = Time::getTimeNanoseconds();
232 "Process::getThread(" <<
Dec << n <<
Hex 233 <<
") - Parameter out of bounds.");
243 #ifdef VERBOSE_KERNEL 247 NOTICE(
"Kill: " <<
m_Id <<
" (parent: <orphan>)");
255 if (pProcess && (pProcess->
m_pParent ==
this))
277 "Process::kill() - process is an orphan, adding to ZombieQueue.");
283 FATAL(
"Process: should never get here");
287 #ifdef VERBOSE_KERNEL 289 "Process::kill() - not adding to ZombieQueue, process has a parent.");
292 Thread::Zombie,
nullptr, &
m_Lock);
294 FATAL(
"Should never get here");
329 int64_t Process::getGroupId()
const 338 int64_t Process::getEffectiveUserId()
const 347 int64_t Process::getEffectiveGroupId()
const 361 void Process::addWaiter(
Semaphore *pWaiter)
366 void Process::removeWaiter(
Semaphore *pWaiter)
371 if ((*it) == pWaiter)
380 size_t Process::waiterCount()
const 408 #endif // defined(THREADS)
Group * getEffectiveGroup() const
void pushBack(const T &value)
void pushBack(const T &value)
bool m_bUnreportedSuspend
virtual void processTerminated()
List< Semaphore * > m_Waiters
static Process * getInit()
static bool getInterrupts()
virtual void acquire()
Acquire full mutual exclusion for all Subsystem resources.
Iterator erase(Iterator &Iter)
Time::Timestamp m_LastKernelEntry
A vector / dynamic array.
bool m_bSharedAddressSpace
virtual int64_t getUserId() const
bool acquire(bool recurse=false, bool safe=true)
MemoryAllocator m_DynamicSpaceAllocator
virtual void threadException(Thread *pThread, ExceptionType eType)
void free(T address, T length, bool merge=true)
static ProcessorInformation & information()
static void switchAddressSpace(VirtualAddressSpace &AddressSpace)
VirtualAddressSpace * m_pAddressSpace
Time::Timestamp m_LastUserspaceEntry
Special wrapper object for Process.
void removeProcess(Process *pProcess)
Vector< Thread * > m_Threads
Atomic< size_t > m_NextTid
MemoryAllocator & getDynamicSpaceAllocator()
Group * m_pEffectiveGroup
static Scheduler & instance()
static Process * m_pInitProcess
Process * getProcess(size_t n)
static void setInterrupts(bool bEnable)
static void setInit(Process *pProcess)
Thread * getThread(size_t n)
DynamicLinker * m_pDynamicLinker
VirtualAddressSpace * getAddressSpace()
size_t addProcess(Process *pProcess)
MemoryAllocator m_SpaceAllocator
virtual void revertToKernelAddressSpace()=0
void removeThread(Thread *pThread)
User * getEffectiveUser() const
virtual VirtualAddressSpace * clone(bool copyOnWrite=true)=0
Thread::Status m_BeforeSuspendState
size_t addThread(Thread *pThread)
virtual void threadRemoved(Thread *pThread)
MemoryAllocator & getSpaceAllocator()