Professional Documents
Culture Documents
h>
#include <stdlib.h>
// Function to add a new job to the linked list, sorted by arrival time
void insertJob(struct Node** headRef, struct Job job) {
struct Node* newNode = (struct Node*) malloc(sizeof(struct Node));
newNode->job = job;
newNode->next = NULL;
// Function to simulate the CPU processing jobs using the SJF algorithm
void sjf(struct Node* head) {
int time = 0;
int main() {
// Define the job queue
struct Job jobQueue[] = {
{1, 0, 10},
{2, 1, 5},
{3, 2, 2},
{4, 3, 7}
};
// Simulate the CPU processing the jobs using the SJF algorithm
sjf(head);
return 0;
}