MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / getrusuage

Method getrusuage

source/kernel/kprocess.cpp:1203–1238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203U32 KProcess::getrusuage(KThread* thread, U32 who, U32 usage) {
1204 U32 userSeconds = 0;
1205 U32 userMicroSeconds = 0;
1206 U32 kernelSeconds = 0;
1207 U32 kernelMicroSeconds = 0;
1208
1209 if (who==0) { // RUSAGE_SELF
1210 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(threadsMutex);
1211 for (auto& t : this->threads ) {
1212 KThread* otherThread = t.value;
1213 U64 userTime = otherThread->getThreadUserTime();
1214 userSeconds += (U32)(userTime / 1000000l);
1215 userMicroSeconds += (U32)(userTime % 1000000l);
1216 kernelSeconds += (U32)(otherThread->kernelTime / 1000000l);
1217 kernelMicroSeconds += (U32)(otherThread->kernelTime % 1000000l);
1218 }
1219
1220 } else if ((S32)who < 0) { // RUSAGE_CHILDREN
1221 klog("getrusuage: RUSAGE_CHILDREN not implemented");
1222 } else { // RUSAGE_THREAD
1223 U64 userTime = thread->getThreadUserTime();
1224 userSeconds = (U32)(userTime / 1000000l);
1225 userMicroSeconds = (U32)(userTime % 1000000l);
1226 kernelSeconds = (U32)(thread->kernelTime / 1000000l);
1227 kernelMicroSeconds = (U32)(thread->kernelTime % 1000000l);
1228 }
1229
1230 // user time
1231 memory->writed(usage, userSeconds);
1232 memory->writed(usage + 4, userMicroSeconds);
1233 // system time
1234 memory->writed(usage + 8, kernelSeconds);
1235 memory->writed(usage + 12, kernelMicroSeconds);
1236 memory->memset(usage+16, 0, 56);
1237 return 0;
1238}
1239
1240U32 symlinkInDirectory(BString currentDirectory, BString target, BString linkpath) {
1241 std::shared_ptr<FsNode> node;

Callers 1

syscall_getrusuageFunction · 0.80

Calls 4

klogFunction · 0.85
getThreadUserTimeMethod · 0.80
memsetMethod · 0.80
writedMethod · 0.45

Tested by

no test coverage detected