PCB¶
Process Control Block methods.
- Authors
Luca Donno, Antonio Lopez, Samuele Marro, Edoardo Merli
- Version
0.2.0
- Date
2021-02-13
Functions
-
void initPcbs()¶
Initializes the PCBs.
- Remark
This function should be called before any other PCB-related function.
-
void freePcb(pcb_t *p)¶
Deallocates the PCB.
- Remark
After calling this function, the PCB can’t be used anymore.
- Parameters
p – PCB to be released.
-
pcb_t *allocPcb()¶
Allocates a PCB and returns it.
All the records are cleaned before the allocation.
- Returns
The allocated PCB. Returns NULL if memory is not available.
-
int emptyProcQ(pcb_t *tp)¶
Checks if a process queue is empty.
- Remark
TRUE and FALSE are defined in umps3/umps/const.h.
- Parameters
tp – Queue to be checked.
- Returns
TRUE if tp is empty, FALSE otherwise.
-
void insertProcQ(pcb_t **tp, pcb_t *p)¶
Inserts a PCB in a queue.
- Parameters
tp – Pointer to the queue (sentinel).
p – Pointer to the PCB to be inserted.
-
pcb_t *headProcQ(pcb_t *tp)¶
Returns a pointer to the head of the process queue, without removing it.
- Parameters
tp – Pointer to the tail of the process queue.
- Returns
A pointer to the head of the queue. Returns NULL if the queue is empty.
-
pcb_t *removeProcQ(pcb_t **tp)¶
Removes the head of the PCB queue.
- Parameters
tp – Pointer to the queue (sentinel).
- Returns
A pointer to the removed PCB.
-
pcb_t *outProcQ(pcb_t **tp, pcb_t *p)¶
Removes the PCB pointed by p from the process queue pointed by tp and returns it.
- Parameters
tp – Pointer to the queue (sentinel).
p – Pointer to the PCB to be removed.
- Returns
A pointer to the removed PCB. Retuns NULL if the PCB pointed by p is not in the queue.
-
int emptyChild(pcb_t *p)¶
Checks whether the PCB pointed by p has children.
- Remark
TRUE and FALSE are defined in umps3/umps/const.h.
- Parameters
p – Pointer to the PCB to be checked.
- Returns
TRUE if the PCB pointed by p doesn’t have any children, FALSE otherwise.
-
void insertChild(pcb_t *prnt, pcb_t *p)¶
Inserts the PCB pointed by p as a child of the PCB pointed by prnt.
- Parameters
prnt – Pointer to the PCB who will become parent of p.
p – Pointer to the PCB who will become child of prnt.