1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
coldgirl [10]
3 years ago
13

Provide relevant parts of C-like codes for processes X1, X2, X3, X4 and X5 in the following synchronization problem. Each proces

s has a special (synchronization) point in its code, and:- Process X1 may cross its synchronization point unconditionally- Process X4 has to wait for processes X3 and X1 to cross or reach their synchronization points, and only then X4 may cross its synchronization point,- Process X2 has to wait for process X1 to cross or reach its synchronization point, and only then X2 may cross its synchronization point,- Process X3 has to wait for process X4 to cross or reach its synchronization point, and only then X3 may cross its synchronization point,- Process X5 has to wait for processes X1, X3 and X4 to cross their synchronization points, and only then X5 may cross its synchronization point.Assume that each process will cross its synchronization point only once.
Engineering
1 answer:
labwork [276]3 years ago
3 0

Answer:

import java.util.concurrent.Semaphore;

public class synchronization implements Runnable {

Semaphore b11 = new Semaphore(1);

@Override

//run method

public void run() {

boolean flvalue=false;

System.out.println("Started");

while(!flvalue) {

System.out.println("Thread is running");

}

System.out.println("Stopped");

}

//main method

public static void main(String args[]) {

final synchronization t11 = new synchronization();

Thread x1=new Thread(){

@Override

//run method

public void run(){

t11.mutualExclusion();

}

};

Thread x2=new Thread(){

@Override

//run method

public void run(){

t11.mutualExclusion();

}

};

Thread x3=new Thread(){

@Override

//run method

public void run(){

t11.mutualExclusion();

}

};

Thread x4=new Thread(){

@Override

//run method

public void run(){

t11.mutualExclusion();

}

};

Thread x5=new Thread(){

@Override

//run method

public void run(){

t11.mutualExclusion();

}

};

x1.start();

x2.start();

x3.start();

x4.start();

x5.start();

 

}

private void mutualExclusion() {

try {

b11.acquire();

//mutual value

String tn=Thread.currentThread().getName();

String numberOy= tn.replaceAll("[^0-9]", "");

int num=Integer.parseInt(numberOy)+1;

System.out.println("Thread "+num + " is running");

Thread.sleep(100);

} catch (InterruptedException ie11) {

ie11.printStackTrace();

} finally {

b11.release();

String tn11=Thread.currentThread().getName();

String numberOy= tn11.replaceAll("[^0-9]", "");

int numval=Integer.parseInt(numberOy)+1;

System.out.println("Thread "+numval + " completed...!!!");

}

}

 

}

Explanation:

You might be interested in
(25%) A well-insulated compressor operating at steady state takes in air at 70 oF and 15 psi, with a volumetric flow rate of 500
lubasha [3.4K]

Answer:

You can look it up

Explanation: if you don't know what it is look it up on .

6 0
3 years ago
Can some one plz give me brainlys
Brums [2.3K]

Answer:

how do u do that?

Explanation:

confusion

7 0
2 years ago
Read 2 more answers
The melting point of Pb (lead) is 327°C, is the processing at 20°C hot working or cold working?
bonufazy [111]

Answer:

Explained

Explanation:

Cold working: It is plastic deformation of material at temperature below   recrystallization temperature. whereas hot working is deforming material above the recrystallization temperature.

Given melting point temp of lead is 327° C and lead recrystallizes at about

0.3 to 0.5 times melting temperature which will be higher that 20°C. Hence we can conclude that at 20°C lead will under go cold working only.

6 0
3 years ago
I don’t understand this
blondinia [14]

Answer:

Sorry for the delayed response- Right now I don't have time to give you the answer, but I really want to help so I'll try to phrase it in a easier way to understand things: Basically what you need to do for this problem is find the area of the base of the figure (which means length x width) and then you would simply find the volume of 160cm^{2} by finding the length of each side of the figure, find the length of the figure, find the height of the figure and then find the radius.

Have an amazing day and I hope this can somewhat help :)

7 0
3 years ago
You are NASA. Build a space station on Mars that could support humans to live in for an extended period of time.
Ierofanga [76]
Literally just do the project
3 0
3 years ago
Other questions:
  • Describe the meaning of the different symbols and abbreviations found on the drawings/documents that they use (such as BS8888, s
    12·1 answer
  • Three tool materials (high-speed steel, cemented carbide, and ceramic) are to be compared for the same turning operation on a ba
    10·1 answer
  • A large heat pump should upgrade 5 MW of heat at 85°C to be delivered as heat at 150°C. Suppose the actual heat pump has a COP o
    15·1 answer
  • You are analyzing an open-return wind tunnel that intakes air at 20 m/s and 320K. When the flow exits the wind tunnel it is movi
    14·2 answers
  • Uber drivers are considered 'independent contractors' and thus can apply for business licenses.
    11·2 answers
  • Pls help me with these 3 ez questions.
    8·2 answers
  • What is the probability that Tina will NOT wear a white t-shirt on the first day of her trip?
    12·1 answer
  • Technician A says that 5W-30 would be better to use than 20W-50 in most vehicles in
    7·2 answers
  • The driver should be able to see the ground within _____ to the front?
    14·1 answer
  • The air conditioner in a house or a car has a cooler that brings atmospheric air from 30C to 10C, with both states at 101KPa. If
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!