This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lo scheduler può rimuovere dalla ready queue ed eliminare tutta progenie di un processo #12
- Loading branch information
Showing
5 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <pcb/pcb.h> | ||
|
||
/** | ||
* @brief rimuove tutti i figli di old_parent, aggiungendoli a quelli di new_parent | ||
* @PostCondition Se new_parent == NULL, allora i figli di old_parent saranno senza fratelli e senza padre | ||
* @param old_parent genitore di cui si vuole rimuovere i figli | ||
* @param new_parent il nuovo genitore dei figli | ||
*/ | ||
void pcb_SetChildrenParent( pcb_t* old_parent, pcb_t* new_parent ); | ||
|
||
/** | ||
* @brief Dealloca dopo aver rimosso il descrittore fornito e tutta la sua progenie dalla queue della sentinella fornita | ||
* @PostCondition Non avviene alcuna rimozione nella lista dei fratelli e del padre di p. | ||
* | ||
* @param p descrittore del processo da cui partire a rimuovere la progenie | ||
* @param head queue in cui deve essere rimosso p e tutta la sua progenie | ||
*/ | ||
void pcb_RemoveProgenyQ( pcb_t* p, struct list_head *head ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <pcb/pcb.h> | ||
#include <pcb/utils.h> | ||
|
||
void pcb_SetChildrenParent( pcb_t* old_parent, pcb_t* new_parent ) { | ||
|
||
while( !emptyChild( old_parent ) ) { | ||
pcb_t *child = removeChild( old_parent ); | ||
if( new_parent != NULL ){ | ||
insertChild( new_parent, child ); | ||
} | ||
} | ||
} | ||
|
||
void pcb_RemoveProgenyQ( pcb_t* p, struct list_head *head ) { | ||
if( p == NULL ) | ||
return; | ||
|
||
/** | ||
* Aggiunge ricorsivamente i figli di ogni processo ad uno stack di lavoro | ||
* e poi elimina il padre sia dalla queue | ||
* che dallo stack stesso, con conseguente deallocazione | ||
*/ | ||
LIST_HEAD( pcb_stack ); | ||
list_add( &p->p_next, &pcb_stack ); | ||
|
||
while( !list_empty( &pcb_stack ) ) { | ||
struct list_head *it_parent = list_next( &pcb_stack ); | ||
pcb_t *parent = container_of( it_parent, pcb_t, p_next ); | ||
while( !emptyChild( parent ) ){ | ||
pcb_t* child = removeChild( parent ); | ||
|
||
if( head != NULL ){ | ||
outProcQ( head, parent ); | ||
} | ||
|
||
list_add( &child->p_next, &pcb_stack ); | ||
} | ||
list_del( &parent->p_next ); | ||
freePcb( parent ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters