diff --git a/.vscode/settings.json b/.vscode/settings.json index 45a1188..26a45c3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "types.h": "c", "signal.h": "c", "termios.h": "c", - "stat.h": "c" + "stat.h": "c", + "time.h": "c" } } \ No newline at end of file diff --git a/yeeshell.c b/yeeshell.c index 6778ec1..83b9474 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -35,7 +35,7 @@ char *history[CMDLINE_HISTORY_MAX_QUANTITY]; int cmdline_amount = 0; struct proc *proc = NULL, *prev_proc = NULL; -int nr_total; +int nr_total = 0; unsigned int nr_procs, nr_tasks; int main() @@ -696,3 +696,8 @@ u64_t cputicks(struct proc *p1, struct proc *p2, int timemode) return t; } + +static inline u64_t make64(unsigned long lo, unsigned long hi) +{ + return ((u64_t)hi << 32) | (u64_t)lo; +} \ No newline at end of file diff --git a/yeeshell.h b/yeeshell.h index 8f151f1..f9b251c 100644 --- a/yeeshell.h +++ b/yeeshell.h @@ -15,35 +15,27 @@ #define REDIRECT_OUT 1 /* redirect output */ #define REDIRECT_IN 2 /* redirect input */ -#define _PATH_PROC "/proc/" - -const char *cputimenames[] = {"user", "ipc", "kernelcall"}; -#define CPUTIMENAMES (sizeof(cputimenames) / sizeof(cputimenames[0])) -#define CPUTIME(m, i) (m & (1L << (i))) - -#define PSINFO_VERSION 0 -#define TYPE_TASK 'T' -#define TYPE_SYSTEM 'S' -#define TYPE_USER 'U' -#define STATE_RUN 'R' -#define TIMECYCLEKEY 't' -#define ORDERKEY 'o' - +typedef int endpoint_t; +typedef uint64_t u64_t; +typedef long unsigned int vir_bytes; #define USED 0x1 #define IS_TASK 0x2 #define IS_SYSTEM 0x4 #define BLOCKED 0x8 - -#define ORDER_CPU 0 -#define ORDER_MEMORY 1 -#define ORDER_HIGHEST ORDER_MEMORY - -#define TC_BUFFER 1024 -#define TC_STRINGS 200 - -#define _ENDPOINT_P(e) ((((e) + 1023) % (1023 + ((endpoint_t)0x8ace) + 1)) - 1023) -unsigned int nr_procs, nr_tasks; -#define SLOT_NR(e) (_ENDPOINT_P(e) + nr_tasks) +#define TYPE_TASK 'T' +#define TYPE_SYSTEM 'S' +#define STATE_RUN 'R' +#define MAX_NR_TASKS 1023 +#define SELF ((endpoint_t)0x8ace) +#define _MAX_MAGIC_PROC (SELF) +#define _ENDPOINT_GENERATION_SIZE (MAX_NR_TASKS + _MAX_MAGIC_PROC + 1) +#define _ENDPOINT_P(e) \ + ((((e) + MAX_NR_TASKS) % _ENDPOINT_GENERATION_SIZE) - MAX_NR_TASKS) +#define SLOT_NR(e) (_ENDPOINT_P(e) + 5) +#define _PATH_PROC "/proc" +#define CPUTIME(m, i) (m & (1L << (i))) +const char *cputimenames[] = {"user", "ipc", "kernelcall"}; +#define CPUTIMENAMES (sizeof(cputimenames) / sizeof(cputimenames[0])) struct proc { @@ -104,4 +96,5 @@ void parse_dir(); void parse_file(pid_t pid); void getkinfo(); void print_procs(struct proc *proc1, struct proc *proc2, int cputimemode); -u64_t cputicks(struct proc *p1, struct proc *p2, int timemode); \ No newline at end of file +u64_t cputicks(struct proc *p1, struct proc *p2, int timemode); +static inline u64_t make64(unsigned long lo, unsigned long hi); \ No newline at end of file