Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objectives: Linked list manipulation without standard library support, represent

ID: 3639474 • Letter: O

Question

Objectives: Linked list manipulation without standard library support, representation of a PCB using a struct, implementation of a basic scheduler and practice with C/C++ coding.
Code Requirements: You must implement your own linked list, if you use C++.
Write a program in C/C++ that will simulate the scheduling of processes/jobs. You will need to simulate FIFO (non-preemptive), Priority (preemptive) and Shortest Process Next (preemptive).

Input
Your program should read input from a text file that has the following format Comments

1 3 4 0 Process 1 with priority 3, run time of 4 and arrival time 0

2 5 2 2 Process 2 with priority 5, run time of 2 and arrival time 2

3 2 1 3

4 4 1 4

5 2 3 5
Output

The output will show the order in which the processes run by their process ID.

Sample output
FIFO Order (Non-preemptive) 1 1 1 1 2 2 3 4 5 5 5
Priority Order (Preemptive) 1 1 2 2 4 1 1 3 5 5 5
Shortest Process Next (Preemptive)1 1 1 1 3 4 2 2 5 5 5

The output should be printed directly to the console.

Explanation / Answer

int new_process(DWORD id) { struct stack_node *ptr = free_list; struct stack_node *ptr2 = reserved_list; if (ptr == NULL) return -1; /* Can't allocate more processes */ ptr->Id = id; ptr->next = NULL; if (ptr2 == NULL) { ptr2 = ptr; return 0; } while (ptr2->next) ptr2 = ptr2->next; ptr2->next = ptr; return 0; } void del_process(DWORD id) { struct stack_node *ptr = free_list; struct stack_node *ptr2 = reserved_list; struct stack_node *prv = reserved_list; while (id != ptr2->id) { prv = ptr2; ptr2 = ptr2->next; } prv->next = ptr2->next; ptr2->next = ptr; free_list = ptr2; }