please use pthreads Write a program in C using PTHREAS that will simulate the operations of the following Interactive scheduling algorithm: Round-Robin Your program will implement threads for the algorithm plus the main thread. A linked list will be used to represent the list of jobs available to run. Each node will represent a Job with the following information: int PID Process ID int time The time needed on CPU to finish executing   You will write a thread that will represent the scheduler algorithm. The thread will continue running until all jobs end. This is simulated using the time variable in each node; your program thread will iterate through the linked list jobs until the list is empty. In each iteration, you will subtract a quantum amount from each job to simulate the processing time executing on a CPU. If a node time variables is less than or equal to zero, this will simulate that a process has completed, and it is time to remove this job/node from the list.   Main thread: Ask the user to specify a value to be used as the quantum. Your main code will request the user to input the number of jobs, and then proceed to fill the information in each job node, each data item will be stored in a separate node. Start the RoundRobin Thread and wait till all jobs finish.   RoundRobin thread: The thread will simulate the Round Robin algorithm. Displays data in the list in the order they were inserted. Each iteration of the algorithm, the thread should deduct the quantum amount from each job. If a job time reaches zero, remove this job from the linked list and continue to iterate the list. When there are no more jobs in the list, exit the thread. Here is the sample output: Round Robin simulation program Enter a quantum Value to be used: 2 Enter an ID and a value for a node to add to the list, Enter -1 to stop: 1 5 Enter an ID and a value for a node to add to the list, Enter -1 to stop: 2 4 Enter an ID and a value for a node to add to the list, Enter -1 to stop: 3 1 Enter an ID and a value for a node to add to the list, Enter -1 to stop: -1 -1   RoundRobin Will Start on the following List: Linked List Contain the following values : Node ID 1 with value 5 Node ID 2 with value 4 Node ID 3 with value 1

Oh no! Our experts couldn't answer your question.

Don't worry! We won't leave you hanging. Plus, we're giving you back one question for the inconvenience.

Submit your question and receive a step-by-step explanation from our experts in as fast as 30 minutes.
You have no more questions left.
Message from our expert:
Hi and thanks for your question! Unfortunately we cannot answer this particular question due to its complexity. We've credited a question back to your account. Apologies for the inconvenience.
Your Question:

please use pthreads

Write a program in C using PTHREAS that will simulate the operations of the following Interactive scheduling algorithm:

  • Round-Robin

Your program will implement threads for the algorithm plus the main thread. A linked list will be used to represent the list of jobs available to run. Each node will represent a Job with the following information:

  • int PID
    • Process ID
  • int time
    • The time needed on CPU to finish executing

 

You will write a thread that will represent the scheduler algorithm. The thread will continue running until all jobs end. This is simulated using the time variable in each node; your program thread will iterate through the linked list jobs until the list is empty. In each iteration, you will subtract a quantum amount from each job to simulate the processing time executing on a CPU. If a node time variables is less than or equal to zero, this will simulate that a process has completed, and it is time to remove this job/node from the list.

 

Main thread:

    • Ask the user to specify a value to be used as the quantum.
    • Your main code will request the user to input the number of jobs, and then proceed to fill the information in each job node, each data item will be stored in a separate node.
    • Start the RoundRobin Thread and wait till all jobs finish.

 

RoundRobin thread:

    • The thread will simulate the Round Robin algorithm.
    • Displays data in the list in the order they were inserted.
    • Each iteration of the algorithm, the thread should deduct the quantum amount from each job.
    • If a job time reaches zero, remove this job from the linked list and continue to iterate the list.
    • When there are no more jobs in the list, exit the thread.

Here is the sample output:

Round Robin simulation program

Enter a quantum Value to be used: 2

Enter an ID and a value for a node to add to the list, Enter -1 to stop: 1 5

Enter an ID and a value for a node to add to the list, Enter -1 to stop: 2 4

Enter an ID and a value for a node to add to the list, Enter -1 to stop: 3 1

Enter an ID and a value for a node to add to the list, Enter -1 to stop: -1 -1

 

RoundRobin Will Start on the following List:

Linked List Contain the following values :

Node ID 1 with value 5

Node ID 2 with value 4

Node ID 3 with value 1

Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY