From 6ca621d5068f93c431d268fbd7113901b48d19ff Mon Sep 17 00:00:00 2001 From: Enrico Fraccaroli Date: Wed, 19 Apr 2023 14:24:32 +0200 Subject: [PATCH] Finalize the scheduling test program. --- mentos/src/process/scheduler_feedback.c | 12 --- programs/CMakeLists.txt | 2 - programs/start.c | 111 ------------------------ programs/startERR.c | 5 -- programs/tests/CMakeLists.txt | 11 ++- programs/tests/myProg.c | 7 -- programs/tests/t_schedfb.c | 22 +++++ 7 files changed, 27 insertions(+), 143 deletions(-) delete mode 100644 programs/start.c delete mode 100644 programs/startERR.c delete mode 100644 programs/tests/myProg.c create mode 100644 programs/tests/t_schedfb.c diff --git a/mentos/src/process/scheduler_feedback.c b/mentos/src/process/scheduler_feedback.c index b3ca4fe..dbecb02 100644 --- a/mentos/src/process/scheduler_feedback.c +++ b/mentos/src/process/scheduler_feedback.c @@ -2,18 +2,6 @@ /// @brief Manage the current PID for the scheduler feedback session /// @copyright (c) 2014-2022 This file is distributed under the MIT License. /// See LICENSE.md for details. -/// @details -/// all'avvio di MentOS, usa comando start, verrai avvisato su terminale quando la -/// sessione sarĂ  terminata. Puoi verificare i risultati a video lanciando il -/// comando cat sul file del desktop (feedback.txt) -/// -/// es: -/// ~ start -/// ~ cat feedback.txt -/// -/// Questa e' una versione di prova in cui registriamo una brevissima sessione di -/// soli 10 pid. (Funzionante per ora solo con lo scheduler RR) Istruzioni relative -/// ai parametri della funzione start (che sono work in progress) sono in start.c #include "process/scheduler_feedback.h" #include "hardware/timer.h" diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 2395326..5e36d4c 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -69,8 +69,6 @@ set(PROGRAMS poweroff.c rm.c shell.c - start.c - startERR.c uname.c cat.c echo.c diff --git a/programs/start.c b/programs/start.c deleted file mode 100644 index e4244ec..0000000 --- a/programs/start.c +++ /dev/null @@ -1,111 +0,0 @@ -/// @file start.c -/// @brief Start the scheduler feedback session -/// @copyright (c) 2014-2022 This file is distributed under the MIT License. -/// See LICENSE.md for details. -#include -#include -#include - -#include -#include -#include -#include - -/* -Start, funzionamento: L'utente scrivendo start da shell (interna a MentOS) avviera' la registrazione di un numero -fissato di PID. -Tre tipologie di parametri/flag accettati dalla start: - - -start --> avvia la recording senza alcun parametro (ci aspettiamo file con PID 1 e 2 alternati) - -start -p --> avvia la recording utilizzando anche la funzione fork, cosi da far vedere nel file PID diversi (almeno inizialmente) - -start -f file.c --> avvia la recording lanciando prima il file passato come parametro - -*/ - -//int clonaccio(int, char *); - -int main(int argc, char *argv[]) -{ - int flag = 0; - - if(argc == 1){ - printf("Start Recording\n"); - printf("End Recording\n"); - return 0; - } - else if(argc == 2 && !(strcmp(argv[1],"-p"))){ - - printf("Start Recording\n"); - - for(int i = 0; i < 5; i++){ - - if(fork()==0){ - exit(1); - } - - } - - for(int i = 0; i < 5; i++){ - wait(NULL); - } - - printf("End Recording\n"); - return 0; - - } - else if( argc==3 && !strcmp(argv[1],"-f") ){ - - char destination[] = "../../bin/tests/"; - strcat(destination,argv[2]); - if(fork()==0){ - flag = execl(destination, "customProgram", NULL, NULL); - if(flag == -1){ - execl("../../bin/startERR","error", NULL, NULL); - } - } - wait(NULL); - - /* - if(flag != -1) - { - printf("Start Recording\n"); - printf("End Recording\n"); - }*/ - - int fd; - mode_t flag1 = 000111; - char destination1[] = "../../bin/tests/"; - strcat(destination1,argv[2]); - fd = open(destination1, S_IRUSR, flag1); - if( fd != -1 ){ - printf("Start Recording\n"); - printf("End Recording\n"); - close(fd); - } - else{ - printf("start: file '%s' not found!\n\n", destination1); - } - - - return 0; - } - - if(argc != 1){ - //se arriviamo qui, significa che sono stati passati parametri errati - if(strcmp(argv[1],"-f")){ - printf("start: start has no command '%s'\n\n", argv[1]); - execl("../../bin/startERR","error", NULL, NULL); - } - else{ - printf("start: missing FILE for OPTION '%s'\n\n", argv[1]); - execl("../../bin/startERR","error", NULL, NULL); - } - } - - - /* - if(argc > 1 && (strcmp(argv[1],"-p") && strcmp(argv[1],"-f"))){ //da rafforzare - - }*/ - -} \ No newline at end of file diff --git a/programs/startERR.c b/programs/startERR.c deleted file mode 100644 index ebe8be1..0000000 --- a/programs/startERR.c +++ /dev/null @@ -1,5 +0,0 @@ - -int main(void) -{ - return -1; -} \ No newline at end of file diff --git a/programs/tests/CMakeLists.txt b/programs/tests/CMakeLists.txt index e961136..0055a4e 100644 --- a/programs/tests/CMakeLists.txt +++ b/programs/tests/CMakeLists.txt @@ -61,17 +61,17 @@ set(MENTOS_TESTS_DIR ${CMAKE_SOURCE_DIR}/files/bin/tests) set(TESTS t_mem.c t_fork.c - # Real-time programs + # Test real-time programs. t_periodic1.c t_periodic2.c t_periodic3.c - # Exec + # Testing task execution. t_exec.c t_exec_callee.c # Test environmental variables. t_setenv.c t_getenv.c - # Test: signals. + # Test signals. t_stopcont.c t_sigusr.c t_abort.c @@ -85,9 +85,8 @@ set(TESTS t_kill.c t_itimer.c t_gid.c - - # Testing my program - myProg.c + # Test scheduling feedback tests. + t_schedfb.c ) foreach(TEST ${TESTS}) diff --git a/programs/tests/myProg.c b/programs/tests/myProg.c deleted file mode 100644 index 598de09..0000000 --- a/programs/tests/myProg.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(void) -{ - printf("File di test\n"); - return 0; -} diff --git a/programs/tests/t_schedfb.c b/programs/tests/t_schedfb.c new file mode 100644 index 0000000..81cf020 --- /dev/null +++ b/programs/tests/t_schedfb.c @@ -0,0 +1,22 @@ +/// @file t_schedfb.c +/// @brief Start the scheduler feedback session. +/// @copyright (c) 2014-2022 This file is distributed under the MIT License. +/// See LICENSE.md for details. + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + pid_t cpid; + printf("First test, the child will sleep, thus, they will not be scheduled.\n"); + for (int i = 0; i < 10; ++i) { + if ((cpid = fork()) == 0) { + execl("/bin/tests/t_alarm", "t_alarm", NULL); + return 0; + } + } + while (wait(NULL) != -1) continue; + return 0; +} \ No newline at end of file