From 40fac6e194bb094ef16e9f407676732cfee8fb68 Mon Sep 17 00:00:00 2001 From: tommyvilo <50549764+tommyvilo@users.noreply.github.com> Date: Sat, 18 Mar 2023 21:09:29 +0100 Subject: [PATCH] Add files via upload --- mentos/src/process/feedbackScheduler.c | 40 ++++++++++++++++++++++++ mentos/src/process/scheduler_algorithm.c | 8 +++++ 2 files changed, 48 insertions(+) create mode 100644 mentos/src/process/feedbackScheduler.c diff --git a/mentos/src/process/feedbackScheduler.c b/mentos/src/process/feedbackScheduler.c new file mode 100644 index 0000000..700c480 --- /dev/null +++ b/mentos/src/process/feedbackScheduler.c @@ -0,0 +1,40 @@ +//#include "../fs/open.c" +//NB diocaro: dopo 2 ore ho scoperto che il bro ha ridefinito le open, le close, le write con la dicitura "sys_" davanti +//sta tutto in /mentos/src/fs/..... + +#include "fcntl.h" +#include "stdio.h" + + +int writeFeedback() +{ + mode_t mode = 000777; + char buffer[100 + 1]; + const char* name = "feedback.txt"; + + + int fptr = 0; + //fptr = sys_open("/../../../files/home/feedback.txt", O_WRONLY | O_CREAT | O_TRUNC , mode); + //fptr = sys_open("/../../../files/home/feedback.txt", O_RDONLY | O_CREAT | O_EXCL , mode); + //fptr = sys_open("/../../../files/home/feedback.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + fptr = sys_open(name, O_CREAT | O_WRONLY , S_IRUSR | S_IWUSR); + + if(fptr == -1){ + printf("suca"); + return 0; + } + + + // Reading up to MAX_READ bytes from STDIN. + ssize_t numRead = sys_read(fptr, buffer, 100); + + buffer[numRead] = '\0'; + printf("Input data: %s\n", buffer); + + + //write to file + //sys_write(fptr,"ciao",4); + //printf("suca"); //questo va + sys_close(fptr); //il problema è qui, se chiudiamo il file non arriviamo al login, se non chiudiamo il file invece proviamo a fare login ma non riusciamo perchè non riesce ad aprire passwd + return 1; +} \ No newline at end of file diff --git a/mentos/src/process/scheduler_algorithm.c b/mentos/src/process/scheduler_algorithm.c index bc8537c..115577e 100644 --- a/mentos/src/process/scheduler_algorithm.c +++ b/mentos/src/process/scheduler_algorithm.c @@ -18,6 +18,9 @@ #include "process/wait.h" #include "process/scheduler.h" +//scheduler feedback files +#include "feedbackScheduler.c" + /// @brief Updates task execution statistics. /// @param task the task to update. static void __update_task_statistics(task_struct *task); @@ -44,6 +47,8 @@ static inline task_struct *__scheduler_rr(runqueue_t *runqueue, bool_t skip_peri if (list_head_size(&runqueue->curr->run_list) <= 1) { return runqueue->curr; } + + // Search for the next task (we do not start from the head, so INSIDE, skip the head). list_for_each_decl(it, &runqueue->curr->run_list) { @@ -59,8 +64,11 @@ static inline task_struct *__scheduler_rr(runqueue_t *runqueue, bool_t skip_peri if (__is_periodic_task(entry) && skip_periodic) continue; // We have our next entry. + + int c = writeFeedback(); //prova di stampa return entry; } + return NULL; }