-
-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
darwin: not every process should be in running state (#1611) #1617
Conversation
Linting complains as follows: |
c7ea3df
to
7009789
Compare
@fasterit Thanks, fixed |
This works as intended. Good work! |
Just tested this PR and it seems to work great. I would argue it shows more status than macOS's There is another "stuck" state that are shown in macOS's (I tested this with a little program called stress that can generate workloads, and I can occasionally see "stuck" states with ![]() |
Reduce one level of indent by tweaking the conditional. No changes in code behavior.
I also think that it could be a good future enhancement |
Thank you @BenBE |
Please get an understanding what "stuck" tasks are and how to identify them. This is so we don't have to completely rewrite the logic yet again. I'd like to be sure this can be an incremental change. |
@fasterit in Anyway, by using public APIs (like the one we are using from sysctl or libproc) it's not so straightforward how to get this information. Probably we can get it by adding another syscall that shows us if a process is waiting for resources, and then we could do something like if (ps->state == SLEEPING && isWaitingForResources(ps)) {
ps->state = STUCK;
} Although it's not clear to me which syscall shows the most reliable info in this respect, as far as I know, it should be an incremental change, because the set of stuck processes is a subset of sleeping processes. |
If the change logically still belongs to this issue, you can just add additional commits to this PR. |
This deduces the RUNNING state from the proc_taskinfo structure by using the number of running threads. Fixes: htop-dev#1611
This uses kinfo_procs to deduce some further states, that were not covered in the libproc code. Co-authored-by: aestriplex <[email protected]> Co-authored-by: Benny Baumann <[email protected]>
Thank you @BenBE. |
As this PR and #1622 are currently blocking for the next release of htop, I'd appreciate, if we could avoid feature-creeping the changes in the first iteration and where sensible postpone these nice-to-have extensions to 3.4.1. As it is rn we already improved handling of process state quite a bit over the previous release, thus there's no need to hurry things along more than necessary. If you're okay with this, I'd suggest we put this PR and #1622 for the current release and do all further enhancements in the next (minor) release. |
@BenBE Sounds good to me |
This PR follows from the discussion in #1611
Summary:
ProcessTable_mapDarwinProcessState
;proc->super.state = pti.pti_numrunning > 0 ? RUNNING : SLEEPING;
inDarwinProcess_setFromLibprocPidinfo
;DarwinProcess_setFromLibprocPidinfo
:PROC_PIDTASKINFO_SIZE
instead ofsizeof
.