Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 12.33HW
Program Plan Intro
I/O Multiplexing:
- The idea of I/O multiplexing is to use “select” function to ask kernel to suspend process.
- It returns control to application only after one or more I/O events had occurred.
- It denotes waiting for a set of descriptors that is ready for reading.
- The “select” function would manipulate sets of type “fd_set”, that denotes descriptor sets.
- It takes two inputs: a descriptor set called “read set” and cardinality of read set.
- It blocks until at least one descriptor in read set is ready for reading.
- A descriptor “k” is ready for reading if and only if a request to read 1 byte from that descriptor would not block.
- The “fd_set” is been modified that points to argument “fdset” to indicate subset of read set called “ready set”.
- The value returned by function indicates cardinality of ready set.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C program to implement threading.a. Use following two Arraysa. Student ID[]={101,102,103,104,105}b. Student Results[]={85,45,55,65,75}b. Thread1 prints the student IDs of those students who has 1st and 2nd highest marks.c. Thread 2 prints the IDs of failed studentsd. Thread3 prints avg marks of the class
Write a test client TestBinarySearch.java for use in testing the implementations of min(), max(), floor(), ceiling(), select(), rank(),deleteMin(), deleteMax(), and keys() that are given in the text. Start with the standard indexing client given on page 370. Add code to take additional command-line arguments, as appropriate.Write a test client TestBinarySearch.java for use in testing the implementations of min(), max(), floor(), ceiling(), select(), rank(),deleteMin(), deleteMax(), and keys() that are given in the text. Start with the standard indexing client given on page 370. Add code to take additional command-line arguments, as appropriate.Write a test client TestBinarySearch.java for use in testing the implementations of min(), max(), floor(), ceiling(), select(), rank(),deleteMin(), deleteMax(), and keys() that are given in the text. Start with the standard indexing client given on page 370. Add code to take additional command-line arguments, as appropriate.Write a test client…
Could you assist me with this code? I'm struggling to comprehend how to implement it. The code should be written in C and must involve a 5 x 5 matrix. I have the provide the question and my code.
You need to use the pthread for matrix multiplication. Each threadfrom the threadpool should be responsible for computing only a partof the multiplication (partial product as shown in the above picture –all Ti(S) are called a partical product). Your main thread should splitthe matrices accordingly and create the partial data arrays that areneeded to compute each Ti. You must create a unique task with thedata and submit it to the job queue. You can compute the partialproducts concurrently as long as you have threads available in thethreadpool. You have to remove the task the from queue and submitto a thread in the threadpool. You should define the number ofthreads to be 5 and keep it dynamic so that we can test the samecode with a higher or lower number of threads as needed. When allthe partial…
Chapter 12 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 12.1 - Prob. 12.1PPCh. 12.1 - Prob. 12.2PPCh. 12.2 - Practice Problem 12.3 (solution page 1036) In...Ch. 12.2 - Practice Problem 12.4 (solution page 1036) In the...Ch. 12.4 - Prob. 12.5PPCh. 12.4 - Prob. 12.6PPCh. 12.5 - Prob. 12.7PPCh. 12.5 - Prob. 12.8PPCh. 12.5 - Prob. 12.9PPCh. 12.5 - Prob. 12.10PP
Ch. 12.6 - Prob. 12.11PPCh. 12.7 - Prob. 12.12PPCh. 12.7 - Prob. 12.13PPCh. 12.7 - Prob. 12.14PPCh. 12.7 - Prob. 12.15PPCh. 12 - Prob. 12.20HWCh. 12 - Derive a solution to the second readers-writers...Ch. 12 - Prob. 12.22HWCh. 12 - Prob. 12.23HWCh. 12 - Prob. 12.24HWCh. 12 - Prob. 12.25HWCh. 12 - Prob. 12.26HWCh. 12 - Some network programming texts suggest the...Ch. 12 - Prob. 12.28HWCh. 12 - Prob. 12.29HWCh. 12 - Prob. 12.30HWCh. 12 - Implement a version of the standard I/O fgets...Ch. 12 - Prob. 12.32HWCh. 12 - Prob. 12.33HWCh. 12 - Prob. 12.34HWCh. 12 - Prob. 12.35HWCh. 12 - Prob. 12.36HWCh. 12 - Prob. 12.37HWCh. 12 - Prob. 12.38HWCh. 12 - Prob. 12.39HW
Knowledge Booster
Similar questions
- Write a MultiThreaded ServerSocket Program in C# that can handle multiple clients at the same time. a C# Server Socket use TcpListener Class and listen to PORT 9393. When the C# Server Socket gets a request from Client side, the Server passes the instance of the client request to a separate class handleClient. For each Client request, there is a new thread instant is created in C# Server for separate communication with Client.arrow_forwardConsider the movie ticket booking Application. The Application need to book the ticket with the following assumptions. Total number of seats-500 Cost of the ticket-150 Maximum tickets can be booked by a single user-10. Develop a java code for booking the ticket with the help of JAVA multi-threading .Apply the advantage of having synchronized block in Java. You need to implement a high-performance cache, which allows multiple readers, but how will you implement the single writer to keep the integrity?arrow_forwardHello, could you assist me with this code? I'm encountering difficulties and I'm unsure how to proceed. The code needs to be written in C. I've included my current code below for reference.question:You need to use the pthread for matrix multiplication. Each thread from the threadpool should be responsible for computing only a part of the multiplication (partial product as shown in the above picture –all Ti(S) are called a partical product). Your main thread should split the matrices accordingly and create the partial data arrays that are needed to compute each Ti. You must create a unique task with thedata and submit it to the job queue. You can compute the partial products concurrently as long as you have threads available in the threadpool. You have to remove the task the from queue and submitto a thread in the threadpool. You should define the number of threads to be 5 and keep it dynamic so that we can test the same code with a higher or lower number of threads as needed. When…arrow_forward
- I am getting Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException error for SportsBus and Party Bus instruction: WorkArea is then to be adjusted to implement the method loadBuses. The starting code includesthe skeleton of the method, which includes the method header and the name of the file to beaccessed. . Complete the method loadBuses(String bfile) that reads information bus information from afile (bfile contains the filename) . Each row in the file should trigger the creation of aninstance of bus or an appropriate subclass, according to the data in table 1. All buses createdshould be added to an arraylist. LoadBuses should return the populated arraylist. look at image uploaded it SportsBus and PartyBus are giving index out of bound erros please fix public ArrayList<Bus> loadBuses(String vfile ) { Scanner bscan = null; ArrayList<Bus> blist = new ArrayList<Bus>(); try { bscan = new Scanner(new…arrow_forwardThis is some code in C for quicksort. The quicksort works correctly, but I am trying to implement multithreading. I am trying to run the recursive calls in parallel with a limit on how much threads can be running at one time (set by the global variable 'maximumThreads'). My logic is incorrect with managing how many threads can be ran at the same time. The part that I need you to look at is after the for loop in quick sort, where I have my logic for the mutex and the conditional variable. Right now when I run my code, the program runs without stopping. I would like help with correctly implementing this. #include <stdlib.h>#include <string.h>#include <pthread.h>#include <stdio.h>#define SORT_THRESHOLD 40typedef struct _sortParams {char** array;int left;int right;int* currentThreads;pthread_mutex_t* mutex;pthread_cond_t* cond_var} SortParams;static int maximumThreads; /* maximum # of threads to be used *//* This is an implementation of insert sort, which although…arrow_forwardThis is some code in C for quicksort. The quicksort works correctly, but I am trying to implement multithreading. I am trying to run the recursive calls in parallel with a limit on how much threads can be running at one time (set by the global variable 'maximumThreads'). My logic is incorrect with managing how many threads can be ran at the same time. The part that I need you to look at is after the for loop in quick sort, where I have my logic for the mutex and the conditional variable. Right now when I run my code, the program runs indefinitely. I would like help with correctly implementing this part. #include <stdlib.h>#include <string.h>#include <pthread.h>#include <stdio.h>#define SORT_THRESHOLD 40typedef struct _sortParams {char** array;int left;int right;int* currentThreads;pthread_mutex_t* mutex;pthread_cond_t* cond_var} SortParams;static int maximumThreads; /* maximum # of threads to be used *//* This is an implementation of insert sort, which…arrow_forward
- Problem: Implement a part of functionality for the Netflix DVD queue. It's a service that allows a user to create a list of desired movies and then sends DVDs with movies on top of this list to the subscriber one at a a time. A subscriber should be able to create a list of desired movies and manipulate the order in a movie queue in their account. Your program will implement some of the desired functionality by storing the list of movie titles in a linked list. You are provided with the following files available in "Downloadable files" section: MovieList.h contains a class declaration for the class that represents a list of movies. Driver.cpp contains a main function you can use to test your implementation. You will be responsible for providing the MovieList.cpp file, including the implementation of the MovieList member functions (described below): MovieList and ~MovieList: creates an empty list, and deallocates all the nodes in the list, respectively. display(ostream& out) Print…arrow_forwardImplement the producer consumer problem (also known as bounded buffer problem) in java. create two threads i.e. the producer thread and the consumer thread. Create a shared buffer object using a LinkedList or Queue. The producer adds data to the buffer and the consumer removes data from the buffer. The producer cannot add data if the buffer is full and the consumer cannot remove data from the buffer if it is empty. Make sure there are no race conditions and deadlocks.arrow_forwardComplete the following code. The goal is to implement the producer-consumer problem. You are expected to extend the provided C code to synchronize the thread operations consumer() and producer() such that an underflow and overflow of the queue is prevented. You are not allowed to change the code for implementing the queue operations, that is the code between lines 25 and 126 as shown in the screenshot. You must complete the missing parts as shown in the screenshot as well as complete the missing codes of producer and consumer. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include <pthread.h> #include <semaphore.h> #include <errno.h> #include <fcntl.h> #define MAX_LENGTH_CAP 100 #define INIT -127 #define UNDERFLOW (0x80 + 0x02) #define OVERFLOW 0x80 + 0x01 #define BADPTR (0x80 + 0x03) #define CONSUMER_TERMINATION_PROBABILITY 40 #define PRODUCER_TERMINATION_PROBABILITY 30 // ============= LOCKED…arrow_forward
- Define a class MyData that holds an instance variable x, a function to increment x by 5, and a getter to return the value of x. In a MyUtil class, define an aggregate relationship where MyUtil holds a MyData reference. MyUtil should extend Thread and provide an implementation for run that contains a for loop that iterates 100000 times calling the increment function of the myData reference. Define the main method in MyUtil that creates the instance of MyData. Define a data collection for storing MyUtil objects. In three separate for loops, (1) create and add five instances of MyUtil to the data collection previously defined. (2) Call the start function on each thread. (3) Ensure each thread completes before main completes. Print out the value of x from myData. In a brief comment, describe what is happening when you execute the program several times. Also in the comment, what keyword could be used where to prevent the issue seen?arrow_forwardWrite a code in Ubuntu in only one hour timearrow_forwardProblem: Implement a part of functionality for the Netflix DVD queue. It's a service that allows a user to create a list of desired movies and then sends DVDs with movies on top (what we called head in our lectures) of this list to the subscriber one at a time. A subscriber should be able to create a list of desired movies and manipulate the order in a movie queue in their account. Your program will implement some of the desired functionality by storing the list of movie titles in a linked list. You are provided with the following files available in the "Downloadable files" section: MovieList.h contains a class declaration for the class that represents a list of movies. top refers to the head position of a list and bottom refers to the tail or end position of a list. Driver.cpp contains the main function you can use to test your implementation. *** NOTE: Please do not change any of the function names since our automated test script calls those functions. Changing function names or…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education