diff options
author | Marvin Borner | 2021-04-02 16:17:50 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-02 16:17:50 +0200 |
commit | b62b9d1f33a4911feb9f318ece0c1565f27abf8d (patch) | |
tree | aecea9f7b5bf651b584911cf90c61258b9564556 /kernel/features | |
parent | d055495f3dbb62f74809d31a84621d6e86d61d0a (diff) |
Replaced target macros
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/mm.c | 1 | ||||
-rw-r--r-- | kernel/features/proc.c | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c index afee468..064f78c 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -377,7 +377,6 @@ void *memory_alloc_identity(struct page_dir *dir, u32 flags) return NULL; } -// TODO: Free by address instead of vrange (combine with shmem map?) void memory_free(struct page_dir *dir, struct memory_range vrange) { assert(PAGE_ALIGNED(vrange.base) && PAGE_ALIGNED(vrange.size)); diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 2b2d2d2..8625e7d 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -31,7 +31,10 @@ HOT FLATTEN void scheduler(struct regs *regs) { spinlock(&locked); - PROC(current)->ticks++; + if (RING(regs) == 3) + PROC(current)->ticks.user++; + else + PROC(current)->ticks.kernel++; if (PROC(current)->quantum.cnt >= PROC(current)->quantum.val) { PROC(current)->quantum.cnt = 0; @@ -93,14 +96,14 @@ struct proc *proc_from_pid(u32 pid) iterator = proc_list_blocked->head; while (iterator) { - if (((struct proc *)iterator->data)->pid == pid) + if (PROC(iterator)->pid == pid) return iterator->data; iterator = iterator->next; } iterator = proc_list_running->head; while (iterator) { - if (((struct proc *)iterator->data)->pid == pid) + if (PROC(iterator)->pid == pid) return iterator->data; iterator = iterator->next; } @@ -152,12 +155,15 @@ void proc_exit(struct proc *proc, struct regs *r, s32 status) if (proc->memory->head) { printf("Process leaked memory:\n"); + u32 total = 0; struct node *iterator = proc->memory->head; while (iterator) { struct memory_proc_link *link = iterator->data; printf("\t-> 0x%x: %dB\n", link->vrange.base, link->vrange.size); + total += link->vrange.size; iterator = iterator->next; } + printf("\tTOTAL: %dB (%dKiB)\n", total, total >> 10); } else { printf("Process didn't leak memory!\n"); } |