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
A heat recovery system​ (HRS) is used to conserve heat from the surroundings and supply it to the Mars Rover. The HRS fluid loop
blagie [28]

Answer:

0.304 L of Freon is needed

Explanation:

Q = mCT

Q is quantity of energy that must be removed = 47 BTU = 47×1055.06 = 49587.82 J

C is specific heat of Freon = 74 J/mol.K = 74 J/mol.K × 1 mol/120 g = 0.617 J/g.K

T is temperature in the area of Mars = 189 K

m = Q/CT = 49587.82/(0.617×189) = 452.23 g = 452.24/1000 = 0.45223 kg

Density of Freon = specific gravity of Freon × density of water = 1.49 × 1000 kg/m^3 = 1490 kg/m^3

Volume of Freon = mass/density = 0.45223/1490 = 0.000304 m^3 = 0.000304×1000 = 0.304 L

7 0
3 years ago
How to make text take shape of object in affinity designer
Alina [70]

Answer:

To fit text to a shape in Affinity Designer, make sure you have your text selected. Then, grab the Frame Text Tool and click on the shape. A blinking cursor will appear within the shape, indicating that you can begin typing. The text you type will be confined to the boundaries of the shape.

Explanation:

6 0
3 years ago
8. What are two ways SpaceX plans to change personal travel?
GalinKa [24]

Answer:

as all the people should go near stratosphere

8 0
2 years ago
An electric field is expressed in rectangular coordinates by E = 6x2ax + 6y ay +4az V/m.Find:a) VMN if point M and N are specifi
Fittoniya [83]

Answer:

a.) -147V

b.) -120V

c.) 51V

Explanation:

a.) Equation for potential difference is the integral of the electrical field from a to b for the voltage V_ba = V(b)-V(a).

b.) The problem becomes easier to solve if you draw out the circuit. Since potential at Q is 0, then Q is at ground. So voltage across V_MQ is the same as potential at V_M.

c.) Same process as part b. Draw out the circuit and you'll see that the potential a point V_N is the same as the voltage across V_NP added with the 2V from the other box.

Honestly, these things take practice to get used to. It's really hard to explain this.

3 0
4 years ago
A skilled worker with the ability to operate computer numerically controlled (CNC) machines is qualified to work in which of the
KengaRu [80]

Answer:

Machinist

Explanation:

A skilled worker with the ability to operate computer numerically controlled (CNC) machines is qualified to work in a machinist position.

A machinist is a person who is properly skilled and consists of advanced knowledge regarding the functions of a CNC machine. He can use different mechanisms and complex numerical functions of the machine to carry out different tasks. Any person who lacks the official learning of mechanisms cannot operate such machines effectively.

3 0
3 years ago
Other questions:
  • An old refrigerator consumes 247 W of power. Assuming that the refrigerator operates for 19 hours everyday, what is the annual o
    15·2 answers
  • I dont undertand this coding problem (Java):
    8·1 answer
  • Using the idea of mass and change of speed... could a bowling ball be thrown so fast that it has the same force as a car driving
    7·1 answer
  • A two-phase mixture of water and steam with a quality of 0.63 and T = 300F expands isothermally until only saturated vapor rema
    7·1 answer
  • Define Viscosity. What are the main differences between viscous and inviscid flows?
    10·1 answer
  • Question 3 (5 points)
    7·1 answer
  • You are hired as the investigators to identify the root cause and describe what should have occurred based on the following info
    9·1 answer
  • Engineering practices include which of the following? Select all that apply.
    10·1 answer
  • Random question, does anyone here use Lego, do not answer unless that is a yes
    15·2 answers
  • 7.35 and 7.36 For the beam and loading shown, (a) draw the shear and bending-moment diagrams, (b) determine the maximum absolute
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!