Computer Systems: A Programmer's Perspective (3rd Edition)
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
Question
Book Icon
Chapter 12, Problem 12.29HW
Program Plan Intro

Deadlocks:

  • The deadlock denotes a situation where a collection of threads remains blocked.
  • It denotes waiting for a condition that will never be true.
  • The progress graph denotes invaluable tool for understanding deadlock.
  • If “P” and “V” operations are been ordered incorrectly, the forbidden regions for two semaphores would overlap.
  • If some execution trajectory reaches deadlock state “d” then no further progress is possible.
  • In this case each thread waits for the other one for a “V” operation that never occurs.
  • The overlapping forbidden regions would induce a set of states called “deadlock region”.
  • The deadlock is inevitable is trajectory touches a state in deadlock region.
  • Once it enters deadlock regions, the trajectories could never leave.

Mutex lock ordering rule:

  • A program is deadlock-free if each thread acquires its mutexes in order.
  • It releases them in reverse order and given a total ordering for all mutexes.
  • The mutex should be achieved in order to ensure deadlock free scheme.

Blurred answer
Students have asked these similar questions
// please don't copy from chegg in java: Use multithreading and thread synchronization to code an application simulating a bank deposit and withdrawal process. Set up an account containing an initial balance of $1000.00 for both of the two shared threads, Husband and Wife. When a thread makes a deposit in an account, the other thread must wait. If the account balance is $0.00, no withdrawals are permitted. Assume a deposit transaction requires 0.2 seconds to complete and a withdrawal transaction requires 0.5 seconds to complete. Generate random number 1 as deposit and 2 as withdrawal, respectively. Write a driver class MultiThreadAppt o test your application, repeat, and display the operations 50 times. Document all source code as required above.
Const N = 50; Var Tally: integer; Procedure Total; Var Count:integer; Begin For Count := 1 to N do Tally := Tally + 1 End; End; Begin (* main program *) Tally := 0; Parabegin Total; Total; Paraend; Write (Tally) End. Compose a thread safe pseudocode version that guarantees the upper and lower bound of the shared variable Tally are the same value after execution.
In C++ This exercise involves implementing the solution to the bounded buffer/readers and writers problem using threads. You will create a program that accepts four command line arguments: run_time (the length of time the program should run) buffer_size (number of slots in the bounded buffer) num_producers (number of producer threads) num_consumers (number of consumer threads) The program will create a thread for each producer and consumer. As each thread produces or consumes a data item, it will print its status. Example Output Here are some sample runs: Not enough arguments If not enough arguments are provided, the program should print an error message and exit. $ ./bounded_buffer Wrong number of arguments. Usage: bounded_buffer <run_time> <buffer_size> <num_producers> <num_consumers> $ Invalid argument If an argument is less than or equal to 0, the program should print a message and exit $ ./bounded_buffer 10 5 1 0 ./bounded_buffer 10 5 1 0 num_consumers…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education