MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysGetProcessInfo

Function SysGetProcessInfo

Kernel/src/arch/x86_64/syscalls.cpp:1788–1817  ·  view source on GitHub ↗

//////////////////////// \brief SysGetProcessInfo (pid, pInfo) \param pid - Process PID \param pInfo - Pointer to process_info_t structure \return On Success - Return 0 \return On Failure - Return error as negative value ////////////////////////

Source from the content-addressed store, hash-verified

1786/// \return On Failure - Return error as negative value
1787/////////////////////////////
1788long SysGetProcessInfo(regs64_t* r){
1789 uint64_t pid = SC_ARG0(r);
1790 process_info_t* pInfo = reinterpret_cast<process_info_t*>(SC_ARG1(r));
1791
1792 process_t* cProcess = Scheduler::GetCurrentProcess();
1793 if(!Memory::CheckUsermodePointer(SC_ARG1(r), sizeof(process_info_t), cProcess->addressSpace)){
1794 return -EFAULT;
1795 }
1796
1797 process_t* reqProcess;
1798 if(!(reqProcess = Scheduler::FindProcessByPID(pid))){
1799 return -EINVAL;
1800 }
1801
1802 pInfo->pid = pid;
1803
1804 pInfo->threadCount = reqProcess->threadCount;
1805
1806 pInfo->uid = reqProcess->uid;
1807 pInfo->gid = reqProcess->gid;
1808
1809 pInfo->state = reqProcess->state;
1810
1811 strcpy(pInfo->name, reqProcess->name);
1812
1813 pInfo->runningTime = Timer::GetSystemUptime() - reqProcess->creationTime.seconds;
1814 pInfo->activeUs = reqProcess->activeTicks * 1000000 / Timer::GetFrequency();
1815
1816 return 0;
1817}
1818
1819/////////////////////////////
1820/// \brief SysGetNextProcessInfo (pidP, pInfo)

Callers

nothing calls this directly

Calls 6

GetCurrentProcessFunction · 0.85
CheckUsermodePointerFunction · 0.85
FindProcessByPIDFunction · 0.85
strcpyFunction · 0.85
GetSystemUptimeFunction · 0.85
GetFrequencyFunction · 0.85

Tested by

no test coverage detected