Ask Question, Ask an Expert


Ask C/C++ Expert

Home >> C/C++

Deadlock Avoidance and SJF/LLF Scheduling

In this assignment, you will implement a deadlock avoidance algorithm as part of the process manager to avoid deadlocks in a Unix/Linux system. Part of the assignment requires the manipulation of Unix/Linux processes and part of it consists of simulation.

Both the deadlock-handling process and the processes requesting resources are real Unix/Linux processes created using fork(). However, you do not need to actually allocate any resource. The main process executes the Banker's algorithm. The resource-requesting processes make requests by communicating with the deadlock-handling process with either Unix/Linux pipes or shared memorycontrolled by semaphores (your choice, but pipes are easier to use).

The deadlock-handling process chooses the next process with the shortest computation time (SJF) to be serviced. After having one request serviced, a process has to allow another process to make a request before making another one, that is, another process with the shortest computation time is chosen for service. Ties are broken arbitrarily. A process can also release resources during its execution, and releases all resources held when it terminates.

Associated with each process is also a relative deadline (that is, the deadline from the current time instant). One time unit is needed for servicing each request (whether the resource is allocated or not), so the relative deadline for each process is decreased by 1 whether it is serviced or not. If the resource is allocated for a request, then the computation time of this process decreases by 1; otherwise, the computation time remains the same. If a process misses its deadline, keep servicing its requests but indicate the deadline miss in the output. A release instruction also needs 1 unit of computation time just like a request.

The input format is as follows:

m /* number of resources */
n /* number of processes */
available[1] = number of instances of resource 1
available[m] = number of instances of resource m
max[1,1] = maximum demand for resource 1 by process 1
max[n,m] = maximum demand for resource m by process n
deadline_1 /* an integer, must be >= computation time */
computation_time_1 /* an integer, equal to number of requests and releases */
request(0,1,0,...,2) /* request vector, m integers */
release(0,1,0,...,1) /* release vector, m integers */:
request(1,0,3,...,1) /* request vector, m integers */
deadline_n /* an integer */
computation_time_n /* an integer, equal to number of requests and releases */
request(0,2,0,...,2) /* request vector, m integers */
release(0,1,0,...,2) /* release vector, m integers */
request(1,0,3,...,1) /* request vector, m integers */

For output, print the state of the system after servicing each request: the arrays available, allocation, need, and deadline misses, if any.

Next, let's try LLF (least laxity rst scheduling) instead of SJF. The deadlock-handling process chooses the next process with the least laxity (slack) to be serviced. Laxity (l) is de ned as deadline (d) minus remaining computation time (c) at a speci c time (t), that is, l(t) = d(t) - c(t). Which scheduling technique yields fewer deadline misses?

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91408

Have any Question? 

Related Questions in C/C++

Assignmentthis is the programthis program will use 2

Assignment This is the program: This program will use 2 different data structures to perform the same tasks; a vector and a dynamically sized array Write a complete C++ program that will: Declare a vector of integers wit ...

Programming assignment image processing - pointers class

Programming Assignment: Image Processing - Pointers, Class & Dynamic Data This project is called "Image Processing" which will shrink an input image, convert a color image to gray image , add random noise to an image, ad ...

Assignmentgoals developing problem-solving skills declaring

Assignment Goals: Developing problem-solving skills, declaring variables, multi-way branches, data validation. Problem: Complete Programming Challenge 4.19 in your text book. Do not accept values larger than 10 meters or ...

Assignmentconsider the following declarationsclass

Assignment Consider the following declarations: class bagType { public: void set(string, double, double, double, double); void print() const; string getStyle() const; double getPrice() const; void get(double, double, dou ...

Write a c program that requests the name of any cartoon

Write a C program that requests the name of any cartoon character from the user, then does the following with that name (use printf for each): a. Displays it enclosed in double quotes. b. Displays it in a field 24 charac ...

Write a c application that does the followingitem 1 prompts

Write a C++ application that does the following: ITEM 1: Prompts the user to choose one of the following series: 1 + 1/2 + 1/3 + ... + 1/n ((((x * 2) * 2) * ...) * 2) series of n multiplications x + (x * 1) + (x * 2) + ( ...

Transaction processing system tpsxyz electronics is one of

Transaction Processing System (TPS) XYZ Electronics is one of the most popular electronics companies In Sultanate of Oman the company offers affordable electronic gadgets such as mp3 players, portable movie players, mobi ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while, do - while , and for loops. Add the following to your program: ...

Intro to programming in c assignmentsince this is the last

Intro to Programming in C Assignment Since this is the last assignment, there will be no late submission. All programs must be electronically submitted by 5:00pm on Tuesday, December 2nd with NO EXCEPTIONS in order to re ...

Discussionwhile loops versus for loops please respond to

Discussion "While Loops versus For Loops" Please respond to the following: • Suppose you are writing a C++ program that plays a commercial video continuously within a kiosk at your favorite shopping mall within your home ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen