Ciao ragazzi,
sono nuovo e vorrei delicidazioni sul file list.h
questo serve per gestire le liste nel kernel linux.
come posso usare queste funzioni per gli scopi che elenco qua sotto?
ho definito questo:
static pcb_t *pcbFree_h;/* pointer to the head of pcbFree list */
static pcb_t *pcbTable[20]; /*array di processi*/
ho questa struttura
typedef struct pcb_t {
/*process queue fields */
struct list_head p_next;
/*process tree fields */
struct list_head p_child,
p_sib;
struct pcb_t *p_prnt;
/* processor state, etc */
state_t p_state;
S32 *p_semAdd;
/* ... */
} pcb_t;
devo scrivere queste funzioni, avete delle soluzioni?
/* initialize the pcbFree list (double linked) to contain all the elements of the array pcbTable */
void initPcbs(void);
/* insert the element pointed to by p onto the pcbFree list */
void freePcb(pcb_t *p);
/*ritorna NULL se la pcbFree e` vuota, altrimenti rimuove dalla lista pcbFree, fornisce i valori iniziali per tutti i campi dei processi (per esempio NULL o 0), e ritorna il puntatore all'elemento rimosso*/
pcb_t *allocPcb(void);
/*dovrebbe mettere i campi della struttura a NULL*/
void mkEmptyProcQ(struct list_head *emptylist);
/*ritorna TRUE se la lista e` vuota, altrimenti FALSE*/
int emptyProcQ(struct list_head *head);
/*insert the ProcBlk pointed to by p into the process queue*/
void insertProcQ(struct list_head *head, pcb_t *p);
/* remove the first (i.e. head) ProcBlk from the process queue and return a pointer to it; return NULL if the queue is empty */
pcb_t *removeProcQ(struct list_head *head);
/* remove the ProcBlk pointed to by p from the process queue and return if p; return NULL if the queue is empty or p is not in the queue */
pcb_t *outProcQ(struct list_head *head, pcb_t *p);
/* return a pointer to the first ProcBlk from the process queue; NULL if the process queue is empty */
pcb_t *headProcQ(struct list_head *head);
/* return TRUE if the ProcBlk pointed to by p has no children */
int emptyChild(pcb_t *child);
/* Make the ProcBlk pointed to by parent a child of the ProcBlk pointed to by prnt */
void insertChild(pcb_t *parent, pcb_t *child);
/* if p has children, remove the first one from the tree and return a pointer to it; if parent has no children, return NULL */
pcb_t *removeChild(pcb_t *parent);
/* if p has no parent, return NULL, else remove parent from the tree and return p */
pcb_t *outChild(pcb_t *child);
GRAZIE A TUTTI...