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
Concept explainers
Expert Solution & Answer
Chapter 12.7, Problem 12.12PP
Program Description Answer
The following program code describes about the thread-safe wrapper function for the C standard library ctime function. Here, it uses lock and copy technique to call a class 3 thread unsafe function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these 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.
Consider 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?
JAVA You are requested to implement a “message buffer and response connector” class using Javaprogramming language. The following figure depicts a message buffer and response connectorclass, followed by detailed operations specifications. The message buffer and response connectorclass has three operations, send(), receive(), and reply().Your program should create two separate threads for testing your implementation, a producerthread, and a consumer thread. The producer thread sends a message having a structure (string,integer) – e.g., (add, 3) or (multiply, 7) - to a consumer thread via a message buffer and responseconnector. The consumer thread encapsulates a SimpleCalculation class that has two operations,add() and “multiply(). You should implement the SimpleCalculation class as well. When theconsumer thread receives a message from the connector, it extracts the message and then callsone of the operations on the SimpleCalculation class, depending on the message. For example,the…
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- This 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_forwardIn c++ if possible i have tried everything i can quite get it: Write a thread-safe logger implementation with interface: log(datetime timestamp, string severity, string message) that outputs lines to the console in the format: Timestamp [Severity] Message with the additional requirement that there must be a delay of at least 1 second before the line appears on the console. it must be: a. Exactly one line is printed to the console for each call to log. b. The call to log is non-blocking.arrow_forward
- in c++ language, make a traffic management system using linked lists (strctures ). ( Drop code in words and screenshot of the output as well )arrow_forwardGenerate c++ code to an asynchronous error to add a fallback/secondary queue toour command group submission and to discard synchronous exceptionsthat also happen to be thrown shows such code whichinvokes our handle_async_error function to allow us to experiment.arrow_forwardC++ For this exercise along with a paragraph of description on how you implemented your solution. Imagine you have a call center with employees as agents to receive calls. An incoming telephone call must be allocated to an employee who is free. The customers making the phone calls to a call center are referred to as threads. Think of the scenario as a producer/consumer where producers are the employees working in the call center and your critical section is the phone call simulated with thread function. Implement a thread-based solution where you have at least 5 customer threads. The names of the customers should be Al, Bo, John, Mark, Alex. Please note that when a phone call is made (i.e., the critical section is being executed) the critical section should be secured (either with semaphore or mutex lock). Your sample output should be something like below Welcome to the call center. Please wait for the setup to start Initial operator availability = 3 Alice is waiting to speak to the…arrow_forward
- Create a BST implementation that uses three arrays to represent the BST: one with keys, one with array indices for left links, and one with array indices for right links. The arrays should be preallocated to the maximum size specified in the constructor. Compare your program's performance against that of the usual implementation.arrow_forwardWrite a C program that implements a hash table with chaining for collision resolution. The program should allow the user to add, search, and delete elements from the hash table. When a collision occurs, the program should use a linked list to store multiple elements with the same hash value. The program should also keep track of the number of collisions and provide a way to display the entire hash table.arrow_forwardjava languagearrow_forward
- Distinguish between the Java classes GenericServlet and Http Servlet using an example.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_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_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