Related questions
PLEASE USE PTHREADS
Write a program in C using PTHREADSthat will simulate the operations of the following Batch scheduling algorithms: PLease use Pthreads
- First-Come, First-Served
- Shortest Job First
Your Program will implement threads for each
- int PID
- Process ID
- int time;
- The time needed on CPU to finish executing
Main thread:
-
- Your main code will request the user to input a list of jobs, and to fill the information in each job node until a sentinel value is reached, each data item will be stored in a separate node.
- Starts the FCFS thread, followed by SJF thread.
- Wait for both threads to finish before exiting.
FCFS thread:
-
- The thread will simulate the First-Come, First-Served algorithm.
- Displays the data in a list in the order they were inserted.
SJF thread:
-
- The thread will simulate the Shortest Job First algorithm.
- The thread will compare which job should run depending on the value of time inside the nodes.
- Display nodes according to the shortest job first order.
- You can remove nodes from the list after your display.
Here is the sample output:
Enter an ID and a value for a node to add to the list, Enter -1 to stop: 1 200
Enter an ID and a value for a node to add to the list, Enter -1 to stop: 2 30
Enter an ID and a value for a node to add to the list, Enter -1 to stop: 4 300
Enter an ID and a value for a node to add to the list, Enter -1 to stop: -1 -1
FCFS Job order:
FCFS Jobs will be executed in the order they arrived:
Linked List Contain the following values :
Node ID 1 with value 200
Node ID 2 with value 30
Node ID 4 with value 300
FCFS Done
SJF Jobs Order:
Shortest Job to Run next is with ID: 2 and Time 30
Shortest Job to Run next is with ID: 1 and Time 200
Shortest Job to Run next is with ID: 4 and Time 300
SJF : All Jobs Completed
All Threads completed
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images
- In C++ language. Please look at the instructions and help with program. This is for intermediate not advanced. so help me understand pleasearrow_forwardC++ Program This assignment consists of 2 parts. 1. Append Process: Create a Linked List that will store integers. Using the provided getData() method (See below), append 20 numbers to the Linked List. After loaded, display the data. Start with the Head of the list. Prompt for user to proceed. 2. Insert Process: Delete the contents of the Linked List in part 1. Using the provided getData() method, insert 20 numbers into the list and place them in the list in numerical order (1..X). Do not allow duplicates to be in the list. Hint: Do not allow a duplicate to count as a member of the 20. After loaded, display the data per line in order, starting with the Head of the list. Display the content with a leading increasing number 1- 20. i.e. 11 13 14 20 The result should be a naturally sorted. Do not use the STL list container for this exercise. Use the features described in section - Linked List Operations. Using a Class to manage the linked list as shown in section is...arrow_forwardpython language Write the lines of code that will print out all of the data in a Linked List.arrow_forward
- QueueArray.java This file implements QueueInterface.java This file has * attributes of an array holding queue elements. An integer represents front * index, an integer for rear index, and an integer to keep track number of * elements in the queue. An overloaded constructor accepts an integer for * initializing the queue size, e.g. array size. An enqueue method receives an * object and place the object into the queue. The enqueue method will throw * exception with message "Overflow" when the queue is full. A dequeue method * returns and removes an object from front of the queue. The dequeue method * will throw exception with message "Underflow" when the queue is empty. A size * method returns number of elements in the queue. A toString method returns a * String showing size and all elements in the queue.arrow_forwardwrite a program for a library automation which gets the isbn number, name, author and publication year of the books in the library. the status will be filled by the program as follows: if publication year before 1985 the status is reference else status is available, the information about the books should be stored inside a linked list. the program should have a menu and the user inserts, displays, and deletes the elements from the menu by write a selecting options. the following data structure should be used. struct list char isbn[ 20 ]: char namei 20 ]. char authori 20 ]: int year; char status[200j: struct list "next, jinfo, wedoad n un posn ag pinogs nuu sulnogoj l press 1. to insert a book press 2. to display the book list press 3. to delete a book from listarrow_forwardQ10 Please explain your answersarrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY