20 #include "PosixProcess.h" 23 #include "modules/system/vfs/VFS.h" 24 #include "pedigree/kernel/utilities/utility.h" 28 ProcessGroup::~ProcessGroup()
37 (*it)->setProcessGroup(0,
false);
47 PosixProcess::PosixProcess()
48 :
Process(), m_pSession(0), m_pProcessGroup(0), m_GroupMembership(NoGroup),
49 m_Mask(0), m_RealIntervalTimer(this,
IntervalTimer::Hardware),
51 m_ProfileIntervalTimer(this,
IntervalTimer::Profile), m_Uid(0), m_Gid(0),
52 m_Euid(0), m_Egid(0), m_Suid(0), m_Sgid(0), m_SupplementalIds()
58 PosixProcess::PosixProcess(
Process *pParent,
bool bCopyOnWrite)
59 :
Process(pParent, bCopyOnWrite), m_pSession(0), m_pProcessGroup(0),
60 m_GroupMembership(NoGroup), m_Mask(0),
65 if (pParent->
getType() == Posix)
68 m_pSession = pPosixParent->m_pSession;
69 setProcessGroup(pPosixParent->getProcessGroup());
72 setGroupMembership(
Member);
76 m_Mask = pPosixParent->getMask();
78 m_SupplementalIds.
clear();
79 pPosixParent->getSupplementalGroupIds(m_SupplementalIds);
80 m_Suid = pPosixParent->getSavedUserId();
81 m_Sgid = pPosixParent->getSavedGroupId();
85 m_Gid = pParent->getGroupId();
86 m_Euid = pParent->getEffectiveUserId();
87 m_Egid = pParent->getEffectiveGroupId();
94 PosixProcess::~PosixProcess()
99 void PosixProcess::setProcessGroup(
103 if (m_pProcessGroup && bRemoveFromGroup)
119 m_pProcessGroup = newGroup;
130 return m_pProcessGroup;
133 void PosixProcess::setGroupMembership(
Membership type)
135 m_GroupMembership = type;
140 return m_GroupMembership;
158 void PosixProcess::setMask(uint32_t mask)
163 uint32_t PosixProcess::getMask()
const 170 return m_RobustListData;
175 m_RobustListData = data;
178 void PosixProcess::registerProcess()
190 void PosixProcess::unregisterProcess()
204 return m_RealIntervalTimer;
209 return m_VirtualIntervalTimer;
214 return m_ProfileIntervalTimer;
218 Time::Timestamp user, Time::Timestamp system)
221 m_ProfileIntervalTimer.
adjustValue(-(user + system));
233 : m_Process(pProcess), m_Mode(mode), m_Value(0), m_Interval(0),
234 m_Lock(false), m_Armed(false)
241 t->registerHandler(
this);
246 IntervalTimer::~IntervalTimer()
253 t->unregisterHandler(
this);
259 Time::Timestamp interval, Time::Timestamp *prevInterval)
265 *prevInterval = m_Interval;
267 m_Interval = interval;
271 Time::Timestamp value, Time::Timestamp *prevValue)
277 *prevValue = m_Value;
280 m_Armed = m_Value > 0;
284 Time::Timestamp interval, Time::Timestamp value,
285 Time::Timestamp *prevInterval, Time::Timestamp *prevValue)
291 *prevInterval = m_Interval;
296 *prevValue = m_Value;
299 m_Interval = interval;
301 m_Armed = m_Value > 0;
304 void IntervalTimer::getIntervalAndValue(
305 Time::Timestamp &interval, Time::Timestamp &value)
309 interval = m_Interval;
315 bool needsSignal =
false;
320 if ((adjustment < 0) &&
321 (static_cast<uint64_t>(adjustment * -1) > m_Value))
327 m_Value += adjustment;
330 if (m_Armed && !m_Value)
332 m_Value = m_Interval;
333 m_Armed = m_Value > 0;
345 Time::Timestamp IntervalTimer::getInterval()
const 350 Time::Timestamp IntervalTimer::getValue()
const 362 bool needsSignal =
false;
374 m_Value = m_Interval;
375 m_Armed = m_Value > 0;
420 int64_t PosixProcess::getGroupId()
const 425 int64_t PosixProcess::getEffectiveUserId()
const 430 int64_t PosixProcess::getEffectiveGroupId()
const 437 for (
auto it : m_SupplementalIds)
443 void PosixProcess::setUserId(int64_t
id)
448 void PosixProcess::setGroupId(int64_t
id)
453 void PosixProcess::setEffectiveUserId(int64_t
id)
458 void PosixProcess::setEffectiveGroupId(int64_t
id)
465 m_SupplementalIds.clear();
466 m_SupplementalIds.reserve(vec.
size(),
false);
470 m_SupplementalIds.pushBack(it);
474 int64_t PosixProcess::getSavedUserId()
const 479 int64_t PosixProcess::getSavedGroupId()
const 484 void PosixProcess::setSavedUserId(int64_t
id)
489 void PosixProcess::setSavedGroupId(int64_t
id)
void pushBack(const T &value)
void pushBack(const T &value)
virtual ProcessType getType()
void setInterval(Time::Timestamp interval, Time::Timestamp *prevInterval=nullptr)
Iterator erase(Iterator &Iter)
void removeProcess(PosixProcess *proc)
virtual Timer * getTimer()=0
CPU time in user and system.
virtual int64_t getUserId() const
virtual int64_t getUserId() const
Filesystem * lookupFilesystem(const String &alias)
void setGroupId(size_t gid)
void setTimerValue(Time::Timestamp value, Time::Timestamp *prevValue=nullptr)
Set the current value of the timer.
virtual void processTerminated()
IntervalTimer(PosixProcess *pProcess, Mode mode=Hardware)
virtual void reportTimesUpdated(Time::Timestamp user, Time::Timestamp system)
virtual void timer(uint64_t delta, InterruptState &state)
Thread * getThread(size_t n)
CPU time in user mode only.
List< PosixProcess * > Members
void setIntervalAndValue(Time::Timestamp interval, Time::Timestamp value, Time::Timestamp *prevInterval=nullptr, Time::Timestamp *prevValue=nullptr)
Set both interval and value atomically.
void returnGroupId(size_t gid)
virtual ProcessType getType()
void adjustValue(int64_t adjustment)
Adjust the current value directly.
virtual void sendSignal(Thread *pThread, int signal, bool yield=true)
Hardware-backed timer (wall time).
void clear(bool freeMem=false)
void addProcess(PosixProcess *proc)