aboutsummaryrefslogtreecommitdiffstats
path: root/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'darwin')
-rw-r--r--darwin/DarwinProcess.c22
-rw-r--r--darwin/Platform.c4
-rw-r--r--darwin/Platform.h7
3 files changed, 18 insertions, 15 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 62b6651..95ae960 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -37,11 +37,11 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
- [ST_UID] = { .name = "ST_UID", .title = " UID ", .description = "User ID of the process owner", .flags = 0, },
+ [ST_UID] = { .name = "ST_UID", .title = "UID", .description = "User ID of the process owner", .flags = 0, },
[PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, .defaultSortDesc = true, },
[PERCENT_NORM_CPU] = { .name = "PERCENT_NORM_CPU", .title = "NCPU%", .description = "Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu count)", .flags = 0, .defaultSortDesc = true, },
[PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, .defaultSortDesc = true, },
- [USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
+ [USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
[TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, .defaultSortDesc = true, },
[NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, },
[TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
@@ -331,7 +331,7 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps,
proc->nice = ep->p_nice;
proc->priority = ep->p_priority;
- proc->state = (ep->p_stat == SZOMB) ? 'Z' : '?';
+ proc->state = (ep->p_stat == SZOMB) ? ZOMBIE : UNKNOWN;
/* Make sure the updated flag is set */
proc->updated = true;
@@ -386,7 +386,7 @@ void DarwinProcess_scanThreads(DarwinProcess* dp) {
return;
}
- if (proc->state == 'Z') {
+ if (proc->state == ZOMBIE) {
return;
}
@@ -430,15 +430,15 @@ void DarwinProcess_scanThreads(DarwinProcess* dp) {
vm_deallocate(mach_task_self(), (vm_address_t) thread_list, sizeof(thread_port_array_t) * thread_count);
mach_port_deallocate(mach_task_self(), port);
- char state = '?';
+ /* Taken from: https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/osfmk/mach/thread_info.h#L129 */
switch (run_state) {
- case TH_STATE_RUNNING: state = 'R'; break;
- case TH_STATE_STOPPED: state = 'S'; break;
- case TH_STATE_WAITING: state = 'W'; break;
- case TH_STATE_UNINTERRUPTIBLE: state = 'U'; break;
- case TH_STATE_HALTED: state = 'H'; break;
+ case TH_STATE_RUNNING: proc->state = RUNNING; break;
+ case TH_STATE_STOPPED: proc->state = STOPPED; break;
+ case TH_STATE_WAITING: proc->state = WAITING; break;
+ case TH_STATE_UNINTERRUPTIBLE: proc->state = UNINTERRUPTIBLE_WAIT; break;
+ case TH_STATE_HALTED: proc->state = BLOCKED; break;
+ default: proc->state = UNKNOWN;
}
- proc->state = state;
}
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 3f596a3..152f617 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -126,7 +126,7 @@ static double Platform_nanosecondsPerMachTick = 1.0;
static double Platform_nanosecondsPerSchedulerTick = -1;
-void Platform_init(void) {
+bool Platform_init(void) {
Platform_nanosecondsPerMachTick = Platform_calculateNanosecondsPerMachTick();
// Determine the number of scheduler clock ticks per second
@@ -139,6 +139,8 @@ void Platform_init(void) {
const double nanos_per_sec = 1e9;
Platform_nanosecondsPerSchedulerTick = nanos_per_sec / scheduler_ticks_per_sec;
+
+ return true;
}
// Converts ticks in the Mach "timebase" to nanoseconds.
diff --git a/darwin/Platform.h b/darwin/Platform.h
index c03a9b4..fe75db0 100644
--- a/darwin/Platform.h
+++ b/darwin/Platform.h
@@ -19,6 +19,7 @@ in the source distribution for its full text.
#include "NetworkIOMeter.h"
#include "ProcessLocksScreen.h"
#include "SignalsPanel.h"
+#include "CommandLine.h"
#include "darwin/DarwinProcess.h"
#include "generic/gettime.h"
#include "generic/hostname.h"
@@ -33,7 +34,7 @@ extern const unsigned int Platform_numberOfSignals;
extern const MeterClass* const Platform_meterTypes[];
-void Platform_init(void);
+bool Platform_init(void);
// Converts ticks in the Mach "timebase" to nanoseconds.
// See `mach_timebase_info`, as used to define the `Platform_nanosecondsPerMachTick` constant.
@@ -87,8 +88,8 @@ static inline void Platform_getRelease(char** string) {
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
-static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
- return false;
+static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
+ return STATUS_ERROR_EXIT;
}
static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy