From 325c58f6ae54ad765aa36382295b1eb072ee10d5 Mon Sep 17 00:00:00 2001 From: Otnael Rocha Date: Tue, 10 Dec 2024 02:01:37 -0300 Subject: [PATCH] syscall processInfo --- syscall/processInfo.c | 66 +++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/syscall/processInfo.c b/syscall/processInfo.c index 0b85382a59a2ec..9d0b4e2de748e3 100644 --- a/syscall/processInfo.c +++ b/syscall/processInfo.c @@ -1,26 +1,44 @@ #include - #include - #include - #include - #include "processInfo.h" +#include +#include +#include +#include "processInfo.h" + +asmlinkage long sys_listProcessWaiting(){ + /* + * i) lista os processos em espera + * ii) o processo superior ao parametro limit_age é finalizado + * iii) lista os processos finalizados + * *************************************/ + + //verifique se o estado dele é TASK_RUNNING (em execução), TASK_INTERRUPTIBLE (processo do usuário em sleep). +} + +asmlinkage long sys_listProcessRun(){ + /* + * i) lista os processos em execução + * ii) !avaliar viabilidade de preemptivamente retirar um processo da cpu + * */ +} - asmlinkage long sys_listProcessInfo(long pid, const char __user *buf, int size) { - struct task_struct *proces; - unsigned char kbuf[256]; - int bufsz; - int ret; +asmlinkage long sys_listProcessInfo(long pid, const char __user *buf, int size) { + struct task_struct *proces; + unsigned char kbuf[256]; + int bufsz; + int ret; - /* Find the process */ - for_each_process(proces) { - if( (long)task_pid_nr(proces) == pid){ - /* Print the process info to the buffer */ - snprintf(kbuf, sizeof(kbuf), "Process: %s\n PID_Number: %ld\n Process State: %ld\n Priority: %ld\n RT_Priority: %ld\n Static Priority: %ld\n Normal Priority: %ld\n", - proces->comm, - (long)task_pid_nr(proces), - (long)proces->__state, - (long)proces->prio, - (long)proces->rt_priority, - (long)proces->static_prio, (long)proces->normal_prio); + /* Find the process */ + for_each_process(proces) { + if( (long)task_pid_nr(proces) == pid){ + /* Print the process info to the buffer */ + snprintf(kbuf, sizeof(kbuf), "Process: %s\n PID_Number: %ld\n Process State: %ld\n Priority: %ld\n RT_Priority: %ld\n Static Priority: %ld\n Normal Priority: %ld\n", + proces->comm, + (long)task_pid_nr(proces), + (long)proces->__state, + (long)proces->prio, + (long)proces->rt_priority, + (long)proces->static_prio, + (long)proces->normal_prio); bufsz = strlen(kbuf)+1; /* User buffer is too small */ @@ -32,9 +50,9 @@ ret = copy_to_user((void*)buf, (void*)kbuf, bufsz); return bufsz - ret; - } } - - /* Process not found */ - return -2; } + + /* Process not found */ + return -2; +}