This repository was archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
scheduler : modify.c
sᴀʟᴠᴀᴛᴏʀᴇ ʙ edited this page Jul 17, 2017
·
1 revision
/*
* Modifica la priorità del task specificato, ritorna 1 in caso di successo, altrimenti 0
*/
int modifyById(ReadyQueue *head, unsigned long id) {
if (isEmpty(head)) {
printf("La lista dei task e' vuota.");
return 0;
}
ReadyQueue *found = searchById(head, id);
if (found == NULL) {
printf("Task non trovato nel sistema.");
return 0;
}
byte priority = requestPriority(found);
found->task.priority = priority;
return 1;
}Viene inizialmente verificato che la lista non sia vuota, in caso affermativo si delega a searchById() (funzione appartenente a readyQueue.c ) la ricerca del task. Se esiste viene delegato a requestPriority() l’acquisizione di un nuovo valore e lo si assegna al task.
byte requestPriority(ReadyQueue* found) {
int appo[2] = { 0, 9 };
printf("\nPriorita' attuale:%d", found->task.priority);
byte priority = selectOption("\nInserisci la nuova priorita' (tra 0 e 9): ",
appo, NULL, 0);
return priority;
}Made with ❤️ by Owanesh and MatteoMauro | MIT ©