Skip to content

Commit

Permalink
Fixed updating current process effective priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Mithrandir0x committed Mar 30, 2014
1 parent a62435e commit 912ca6b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 40 deletions.
4 changes: 0 additions & 4 deletions P2-S2/README
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ SPECIAL MACROS AT "kernel.h":

__KRN_DBG_UPDATE_SLEPT_PROCESS__
Defining this macro enables debug logs when process TTS are being updated.

__KRN_DBG_UPDATE_WORKING_PROCESS__
Defining this macro enables debug log when process effective priority is
being updated.
1 change: 0 additions & 1 deletion P2-S2/minikernel/include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,5 @@ servicio tabla_servicios[NSERVICIOS] = {
* Coment out this line to enable debug output when updating BCP's TTS's.
*/
//#define __KRN_DBG_UPDATE_SLEPT_PROCESS__
//#define __KRN_DBG_UPDATE_WORKING_PROCESS__

#endif /* _KERNEL_H */
32 changes: 11 additions & 21 deletions P2-S2/minikernel/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,29 +414,19 @@ static void update_working_process()
int reset_all_bcps_priorities = true;
BCP* p = lista_listos.primero;

for ( ; p ; p = p->siguiente )
{
if ( p->effective_priority > 0 )
{
p->effective_priority--;
p_proc_actual->effective_priority--;

#ifdef __KRN_DBG_UPDATE_WORKING_PROCESS__
print_bcp(p, "update_working_process");
#endif
if ( !p_proc_actual->effective_priority && lista_listos.length != 1 )
{
printk("\x1B[31m[KRN][%2d][%16.16s] PROCESS HAS CONSUMED ALL ITS CPU TIME\x1B[0m\n", p_proc_actual->id, "update_working_process");
SIGNAL_RESCHEDULLING();
}

if ( !p->effective_priority )
{
// Doesn't make much sense to reschedule being only one in the list.
if ( lista_listos.length != 1 )
{
printk("\x1B[31m[KRN][%2d][%16.16s] PROCESS [%2d] HAS CONSUMED ALL ITS CPU TIME\x1B[0m\n", p_proc_actual->id, "update_working_process", p->id);
SIGNAL_RESCHEDULLING();
}
}
else
{
reset_all_bcps_priorities = false;
}
for ( ; reset_all_bcps_priorities && p ; p = p->siguiente )
{
if ( p->effective_priority )
{
reset_all_bcps_priorities = false;
}
}

Expand Down
18 changes: 4 additions & 14 deletions P2-S2/usuario/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,25 @@
*
*/

/* Programa inicial que arranca el S.O. Sólo se ejecutarán los programas
que se incluyan aquí, que, evidentemente, pueden ejecutar otros
programas...
*/

#include "servicios.h"

int main()
{
printf("PID: %d\n", srv_get_current_process_id());
printf("init: comienza\n");

// Has priority 20 and does not sleep
crear_proceso("longsum");

// Has priority 40, but sleeps for 2 seconds
crear_proceso("simplon_prio");

// Has priority 17, but sleeps for 10 seconds
crear_proceso("dormilon");

// Has priority 13 and does not sleep
crear_proceso("getc");

/* Este programa causa una excepción */
//crear_proceso("excep_arit");

/* Este programa crea otro proceso que ejecuta simplon a una excepción */
//crear_proceso("excep_mem");

/* No existe: debe fallar */
//crear_proceso("noexiste");

printf("init: termina\n");

return 0;
Expand Down

0 comments on commit 912ca6b

Please sign in to comment.