Question
How do I implement the alloc_saved_regs function? #include #include #includehomework4.h int main() { int i = 0; for(i = 0;i < 12; i++) { struct
How do I implement the alloc_saved_regs function?
#include
int main() { int i = 0; for(i = 0;i < 12; i++) { struct pcb_type *processControlBlock = create_new_pcb(); add_new_process(processControlBlock); } while(start != NULL) { print_Process(start->pcb_pt); start = start->who_follows; } system("Pause"); return 0; } struct saved_regs * alloc_saved_regs() {
} //creating a new PCB struct pcb_type* create_new_pcb() { struct pcb_type *process = malloc(sizeof(struct pcb_type)); process->proc_class = allocated_class++; process->proc_id = allocated_id++; process->proc_priority = allocated_prio; process->proc_state = 3; return process; } // Adding the pcb to a process_list void add_new_process(struct pcb_type *process) { //Adding to the type process struct process_list *processList = malloc(sizeof(struct process_list)); processList->pcb_pt = process; if(start == NULL) { start = processList; processList->who_follows = NULL; } else { processList->who_follows = start; start = processList; } } //To print the pcbs void print_Process(struct pcb_type *processControlBlock) { printf("index of process: %d ", *processControlBlock); printf("address_pcb = %ud ", &processControlBlock); printf("proc_id = %d ", processControlBlock->proc_id); printf("proc_class = %d ", processControlBlock->proc_class); printf("proc_priority = %d ", processControlBlock->proc_priority); printf("proc_state = %d ", processControlBlock->proc_state); }
#include
struct saved_regs { double reg1, reg2, reg32, reg_pc; }; struct pcb_type { int proc_id; int proc_priority; int proc_state; int proc_class; struct saved_regs *reg_pt; }; struct process_list { struct pcb_type *pcb_pt; struct process_list *who_follows; }; struct process_list *start = NULL; int allocated_id = 1; int allocated_prio = 1; int allocated_class = 1; struct saved_regs *alloc_saved_regs(); struct pcb_type *create_new_pcb(); void add_new_process(struct pcb_type *); void print_Process();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started