feat: added ps command
This commit is contained in:
@@ -27,7 +27,7 @@ void task_suspend();
|
||||
|
||||
pid_t task_get_current_tid();
|
||||
|
||||
void task_signal(uint32_t tid);
|
||||
void task_signal(pid_t tid);
|
||||
|
||||
void task_lock_acquire();
|
||||
|
||||
@@ -35,4 +35,6 @@ void task_ensure_enabled();
|
||||
|
||||
void task_lock_free();
|
||||
|
||||
void task_print_all();
|
||||
|
||||
#endif //NEW_KERNEL_TASK_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/mem/malloc.h>
|
||||
#include <myke/mem/mem.h>
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/util/power.h>
|
||||
|
||||
#ifdef ENABLE_SELF_TEST
|
||||
@@ -50,6 +51,8 @@ void help(const char *args);
|
||||
|
||||
void shutdown(const char *args);
|
||||
|
||||
void ps(const char *args);
|
||||
|
||||
#ifdef ENABLE_SELF_TEST
|
||||
|
||||
void explode(const char *args);
|
||||
@@ -70,6 +73,7 @@ cmd_handler cmd_handlers[] = {
|
||||
{"print", print},
|
||||
{"ide", ide},
|
||||
{"shutdown", shutdown},
|
||||
{"ps", ps},
|
||||
#ifdef ENABLE_SELF_TEST
|
||||
{"slingurl", slingurl},
|
||||
{"kill-self", kill_self},
|
||||
@@ -115,6 +119,10 @@ void shutdown(const char *args) {
|
||||
power_shutdown();
|
||||
}
|
||||
|
||||
void ps(const char *args) {
|
||||
task_print_all();
|
||||
}
|
||||
|
||||
void print_bootinfo() {
|
||||
printf("Bootloader name: %s\n"
|
||||
"cmdline: %s\n",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <myke/libk/syscall.h>
|
||||
|
||||
typedef struct lock_fifo_entry {
|
||||
uint32_t tid;
|
||||
pid_t tid;
|
||||
struct lock_fifo_entry *next;
|
||||
} lock_fifo_entry_t;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <attributes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -103,7 +104,7 @@ pid_t task_get_current_tid() {
|
||||
return current_task->tid;
|
||||
}
|
||||
|
||||
void task_signal(uint32_t tid) {
|
||||
void task_signal(pid_t tid) {
|
||||
task_t *t = first_task;
|
||||
while (t != NULL) {
|
||||
if (t->tid == tid) {
|
||||
@@ -312,3 +313,16 @@ void task_end(pid_t tid) {
|
||||
t = t->next;
|
||||
}
|
||||
}
|
||||
|
||||
void task_print_all() {
|
||||
// acquiring task lock as reference to current task may disappear
|
||||
// might overrun kprint buffer
|
||||
task_lock_acquire();
|
||||
printf("tasks:\n");
|
||||
task_t *c = first_task;
|
||||
while (c != NULL) {
|
||||
printf("%d - %s\n", c->tid, c->name);
|
||||
c = c->next;
|
||||
}
|
||||
task_lock_free();
|
||||
}
|
||||
Reference in New Issue
Block a user