From b74673fe37fd379fc350789e696470556776d815 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Thu, 31 Aug 2023 11:56:43 +1000 Subject: Rename ProcessList to ProcessTable throughout Following up with some discusson from a few months back, where it was proposed that ProcessTable is a better name. This data structure is definitely not a list ... if it was one-dimensional it'd be a set, but in practice it has much more in common with a two-dimensional table. The Process table is a familiar operating system concept for many people too so it resonates a little in that way as well. --- unsupported/UnsupportedProcessList.c | 88 ----------------------------------- unsupported/UnsupportedProcessList.h | 17 ------- unsupported/UnsupportedProcessTable.c | 88 +++++++++++++++++++++++++++++++++++ unsupported/UnsupportedProcessTable.h | 17 +++++++ 4 files changed, 105 insertions(+), 105 deletions(-) delete mode 100644 unsupported/UnsupportedProcessList.c delete mode 100644 unsupported/UnsupportedProcessList.h create mode 100644 unsupported/UnsupportedProcessTable.c create mode 100644 unsupported/UnsupportedProcessTable.h (limited to 'unsupported') diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c deleted file mode 100644 index 1e29c17a..00000000 --- a/unsupported/UnsupportedProcessList.c +++ /dev/null @@ -1,88 +0,0 @@ -/* -htop - UnsupportedProcessList.c -(C) 2014 Hisham H. Muhammad -Released under the GNU GPLv2+, see the COPYING file -in the source distribution for its full text. -*/ - -#include "UnsupportedProcessList.h" - -#include -#include - -#include "ProcessList.h" -#include "UnsupportedProcess.h" - - -ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList) { - UnsupportedProcessList* this = xCalloc(1, sizeof(UnsupportedProcessList)); - Object_setClass(this, Class(ProcessList)); - - ProcessList* super = &this->super; - ProcessList_init(super, Class(Process), host, pidMatchList); - - return this; -} - -void ProcessList_delete(Object* cast) { - UnsupportedProcessList* this = (UnsupportedProcessList*) cast; - ProcessList_done(&this->super); - free(this); -} - -void ProcessList_goThroughEntries(ProcessList* super) { - bool preExisting = true; - Process* proc; - - proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new); - - /* Empty values */ - proc->time = proc->time + 10; - Process_setPid(proc, 1); - Process_setParent(proc, 1); - Process_setThreadGroup(proc, 0); - - Process_updateComm(proc, "commof16char"); - Process_updateCmdline(proc, "", 0, 0); - Process_updateExe(proc, "/path/to/executable"); - - const Settings* settings = proc->host->settings; - if (settings->ss->flags & PROCESS_FLAG_CWD) { - free_and_xStrdup(&proc->procCwd, "/current/working/directory"); - } - - proc->super.updated = true; - - proc->state = RUNNING; - proc->isKernelThread = false; - proc->isUserlandThread = false; - proc->super.show = true; /* Reflected in settings-> "hideXXX" really */ - proc->pgrp = 0; - proc->session = 0; - proc->tty_nr = 0; - proc->tty_name = NULL; - proc->tpgid = 0; - proc->processor = 0; - - proc->percent_cpu = 2.5; - proc->percent_mem = 2.5; - Process_updateCPUFieldWidths(proc->percent_cpu); - - proc->st_uid = 0; - proc->user = "nobody"; /* Update whenever proc->st_uid is changed */ - - proc->priority = 0; - proc->nice = 0; - proc->nlwp = 1; - proc->starttime_ctime = 1433116800; // Jun 01, 2015 - Process_fillStarttimeBuffer(proc); - - proc->m_virt = 100; - proc->m_resident = 100; - - proc->minflt = 20; - proc->majflt = 20; - - if (!preExisting) - ProcessList_add(super, proc); -} diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h deleted file mode 100644 index 96efdcd2..00000000 --- a/unsupported/UnsupportedProcessList.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef HEADER_UnsupportedProcessList -#define HEADER_UnsupportedProcessList -/* -htop - UnsupportedProcessList.h -(C) 2014 Hisham H. Muhammad -Released under the GNU GPLv2+, see the COPYING file -in the source distribution for its full text. -*/ - -#include "ProcessList.h" - - -typedef struct UnsupportedProcessList_ { - ProcessList super; -} UnsupportedProcessList; - -#endif diff --git a/unsupported/UnsupportedProcessTable.c b/unsupported/UnsupportedProcessTable.c new file mode 100644 index 00000000..e0325e4d --- /dev/null +++ b/unsupported/UnsupportedProcessTable.c @@ -0,0 +1,88 @@ +/* +htop - UnsupportedProcessTable.c +(C) 2014 Hisham H. Muhammad +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include "UnsupportedProcessTable.h" + +#include +#include + +#include "ProcessTable.h" +#include "UnsupportedProcess.h" + + +ProcessTable* ProcessTable_new(Machine* host, Hashtable* pidMatchList) { + UnsupportedProcessTable* this = xCalloc(1, sizeof(UnsupportedProcessTable)); + Object_setClass(this, Class(ProcessTable)); + + ProcessTable* super = &this->super; + ProcessTable_init(super, Class(Process), host, pidMatchList); + + return this; +} + +void ProcessTable_delete(Object* cast) { + UnsupportedProcessTable* this = (UnsupportedProcessTable*) cast; + ProcessTable_done(&this->super); + free(this); +} + +void ProcessTable_goThroughEntries(ProcessTable* super) { + bool preExisting = true; + Process* proc; + + proc = ProcessTable_getProcess(super, 1, &preExisting, UnsupportedProcess_new); + + /* Empty values */ + proc->time = proc->time + 10; + Process_setPid(proc, 1); + Process_setParent(proc, 1); + Process_setThreadGroup(proc, 0); + + Process_updateComm(proc, "commof16char"); + Process_updateCmdline(proc, "", 0, 0); + Process_updateExe(proc, "/path/to/executable"); + + const Settings* settings = proc->host->settings; + if (settings->ss->flags & PROCESS_FLAG_CWD) { + free_and_xStrdup(&proc->procCwd, "/current/working/directory"); + } + + proc->super.updated = true; + + proc->state = RUNNING; + proc->isKernelThread = false; + proc->isUserlandThread = false; + proc->super.show = true; /* Reflected in settings-> "hideXXX" really */ + proc->pgrp = 0; + proc->session = 0; + proc->tty_nr = 0; + proc->tty_name = NULL; + proc->tpgid = 0; + proc->processor = 0; + + proc->percent_cpu = 2.5; + proc->percent_mem = 2.5; + Process_updateCPUFieldWidths(proc->percent_cpu); + + proc->st_uid = 0; + proc->user = "nobody"; /* Update whenever proc->st_uid is changed */ + + proc->priority = 0; + proc->nice = 0; + proc->nlwp = 1; + proc->starttime_ctime = 1433116800; // Jun 01, 2015 + Process_fillStarttimeBuffer(proc); + + proc->m_virt = 100; + proc->m_resident = 100; + + proc->minflt = 20; + proc->majflt = 20; + + if (!preExisting) + ProcessTable_add(super, proc); +} diff --git a/unsupported/UnsupportedProcessTable.h b/unsupported/UnsupportedProcessTable.h new file mode 100644 index 00000000..1de8087d --- /dev/null +++ b/unsupported/UnsupportedProcessTable.h @@ -0,0 +1,17 @@ +#ifndef HEADER_UnsupportedProcessTable +#define HEADER_UnsupportedProcessTable +/* +htop - UnsupportedProcessTable.h +(C) 2014 Hisham H. Muhammad +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include "ProcessTable.h" + + +typedef struct UnsupportedProcessTable_ { + ProcessTable super; +} UnsupportedProcessTable; + +#endif -- cgit v1.2.3