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
Nikitich [7]
3 years ago
5

A single-lane bridge connects the two Vermont villages of North Tunbridge and South Tunbridge. Farmers in the two villages use t

his bridge to deliver their produce to the neighboring town. The bridge can become deadlocked of a northbound and a southbound farmer get on the bridge at the same time. (Vermont farmers are stubborn and are unable to back up.)a. Using exactly one semaphore, design an algorithm that prevents deadlock. Do not be
concerned about starvation and inefficency.

b. Provide a solution using Monitor that is starvation-free.

Engineering
1 answer:
Naddika [18.5K]3 years ago
4 0

Answer:

Check the explanation

Explanation:

Main1.java

import java.lang.InterruptedException;

import java.lang.Thread;

import java.util.Random;

public class Main {

final private static int FARMERS = 10;

public static void main(String[] args) {

Bridge bridge = new Bridge();

Random r = new Random();

System.out.println("Running with " + FARMERS + " farmers...");

// Enter a bunch of farmers from different directions.

for (int i = 0; i < FARMERS; i++) {

Farmer farmer;

if (r.nextBoolean()) {

farmer = new SouthBoundFarmer(bridge);

} else {

farmer = new NorthBoundFarmer(bridge);

}

cross(farmer);

}

}

private static void cross(Farmer f) {

new Thread(f).start();

}

}

SouthBoundFarmer.java

public class SouthBoundFarmer extends Farmer {

public SouthBoundFarmer(Bridge b) {

super(b);

this.name = "South";

}

}

Farmer.java

import java.lang.InterruptedException;

import java.util.Random;

public class Farmer implements Runnable {

private Bridge bridge;

private Random random;

protected String name;

public Farmer(Bridge b) {

this.bridge = b;

this.random = new Random();

}

public void crossBridge(Bridge bridge) {

System.out.println("[" + this.name + "] Waiting to enter bridge...");

try {

bridge.enter();

System.out.println("[" + this.name + "] Entering bridge...");

// Crossing bridge...some farmers are fast, others are slow :P

Thread.sleep(1000 + random.nextInt(9000));

System.out.println("[" + this.name + "] Leaving bridge...");

} catch (InterruptedException e) {

System.out.println("...Interrupted!");

} finally {

bridge.leave();

}

}

public void run() {

this.crossBridge(this.bridge);

}

}

Bridge.java

import java.lang.InterruptedException;

import java.util.concurrent.Semaphore;

public class Bridge {

private Semaphore lock;

public Bridge() {

this.lock = new Semaphore(1);

}

public void enter() throws InterruptedException {

this.lock.acquire();

}

public void leave() {

this.lock.release();

}

}

NorthBoundFarmer.java

public class NorthBoundFarmer extends Farmer {

public NorthBoundFarmer(Bridge b) {

super(b);

this.name = "North";

}

}

KINDLY CHECK THE OUTPUT BELOW :

You might be interested in
How to design a solar panel<br>​
artcher [175]

Answer:

#1) Find out how much power you need

#2 Calculate the amount of batteries you need.

#3 Calculate the number of solar panels needed for your location and time of year.

#4 Select a solar charge controller.

#5 Select an inverter.

#6 Balance of system

Explanation: To design solar panel, consider the following steps

1.) Find the power consumption demands

The first step in designing a solar PV system is to find out the total power and energy consumption of all loads that need to be supplied by the solar PV system as follows:

Calculate total Watt-hours per day for each appliance used.

 Add the Watt-hours needed for all appliances together to get the total Watt-hours per day which must be delivered to the appliances.

Calculate total Watt-hours per day needed from the PV modules.

Multiply the total appliances Watt-hours per day times 1.3 (the energy lost in the system) to get the total Watt-hours per day which must be provided by the panels.

2. Size the PV modules

Different size of PV modules will produce different amount of power. To find out the sizing of PV module, the total peak watt produced needs. The peak watt (Wp) produced depends on size of the PV module and climate of site location. We have to consider panel generation factor which is different in each site location. For Thailand, the panel generation factor is 3.43. To determine the sizing of PV modules, calculate as follows:

2.1 Calculate the total Watt-peak rating needed for PV modules

Divide the total Watt-hours per day needed from the PV modules (from item 1.2) by 3.43 to get the total Watt-peak rating needed for the PV panels needed to operate the appliances.

Calculate the number of PV panels for the system

Divide the answer obtained in item 2.1 by the rated output Watt-peak of the PV modules available to you. Increase any fractional part of result to the next highest full number and that will be the 

number of PV modules required.

Result of the calculation is the minimum number of PV panels. If more PV modules are installed, the system will perform better and battery life will be improved. If fewer PV modules are used, the system may not work at all during cloudy periods and battery life will be shortened.

3. Inverter sizing

An inverter is used in the system where AC power output is needed. The input rating of the inverter should never be lower than the total watt of appliances. The inverter must have the same nominal voltage as your battery.

For stand-alone systems, the inverter must be large enough to handle the total amount of Watts you will be using at one time. The inverter size should be 25-30% bigger than total Watts of appliances. In case of appliance type is motor or compressor then inverter size should be minimum 3 times the capacity of those appliances and must be added to the inverter capacity to handle surge current during starting.

For grid tie systems or grid connected systems, the input rating of the inverter should be same as PV array rating to allow for safe and efficient operation.

4. Battery sizing

The battery type recommended for using in solar PV system is deep cycle battery. Deep cycle battery is specifically designed for to be discharged to low energy level and rapid recharged or cycle charged and discharged day after day for years. The battery should be large enough to store sufficient energy to operate the appliances at night and cloudy days. To find out the size of battery, calculate as follows:

     4.1 Calculate total Watt-hours per day used by appliances.

     4.2 Divide the total Watt-hours per day used by 0.85 for battery loss.

     4.3 Divide the answer obtained in item 4.2 by 0.6 for depth of discharge.

     4.4 Divide the answer obtained in item 4.3 by the nominal battery voltage.

     4.5 Multiply the answer obtained in item 4.4 with days of autonomy (the number of days that you need the system to operate when there is no power produced by PV panels) to get the required Ampere-hour capacity of deep-cycle battery.

Battery Capacity (Ah) = Total Watt-hours per day used by appliancesx Days of autonomy

(0.85 x 0.6 x nominal battery voltage)

5. Solar charge controller sizing

The solar charge controller is typically rated against Amperage and Voltage capacities. Select the solar charge controller to match the voltage of PV array and batteries and then identify which type of solar charge controller is right for your application. Make sure that solar charge controller has enough capacity to handle the current from PV array.

For the series charge controller type, the sizing of controller depends on the total PV input current which is delivered to the controller and also depends on PV panel configuration (series or parallel configuration).

According to standard practice, the sizing of solar charge controller is to take the short circuit current (Isc) of the PV array, and multiply it by 1.3

Solar charge controller rating = Total short circuit current of PV array x 1.3

5 0
3 years ago
What’s the answer please help
irina1246 [14]

Answer:

It B

Explanation:

4 0
3 years ago
Q4. (20 points) For a bronze alloy, the stress at which plastic deformation begins is 271 MPa and the modulus of elasticity is 1
babunello [35]

Answer:

a) P = 86720 N

b) L = 131.2983 mm

Explanation:

σ = 271 MPa = 271*10⁶ Pa

E = 119 GPa = 119*10⁹ Pa

A = 320 mm² = (320 mm²)(1 m² / 10⁶ mm²) = 3.2*10⁻⁴ m²

a) P = ?

We can apply the equation

σ = P / A     ⇒    P = σ*A = (271*10⁶ Pa)(3.2*10⁻⁴ m²) = 86720 N

b) L₀ = 131 mm = 0.131 m

We can get ΔL applying the following formula (Hooke's Law):

ΔL = (P*L₀) / (A*E)    ⇒  ΔL = (86720 N*0.131 m) / (3.2*10⁻⁴ m²*119*10⁹ Pa)

⇒  ΔL = 2.9832*10⁻⁴ m = 0.2983 mm

Finally we obtain

L = L₀ + ΔL = 131 mm + 0.2983 mm = 131.2983 mm

3 0
3 years ago
Two steel plates are to be held together by means of 16-mm-diameter high-strength steel bolts fitting snugly inside cylindrical
dusya [7]

Answer:

The outer diameter of the spacers that yields the most economical and safe design is 25.03 mm

Explanation:

For steel bolt

Stress = 210 MPa or 210 N/mm2

Pressure = Stress* Area

Pbolt = 210 N/mm2 * 16^2 *(pi)/4

Pbolt = 210 N/mm2 * 200.96 mm^2 = 42201.6  N

For Brass spacer

Pressure = 42201.6  N

Area of Brass spacer = Pressure/Stress

Area of Brass spacer = 42201.6  N/145 N/mm^2 = 291.044 mm^2

Area of Brass spacer = (pi) (d^2 - 16^2)/4 =  291.044 mm^2

d^2 - 16^2 = 291.044 mm^2* 4/(pi) = 370.758

d^2 =  370.758 + 16^2

d^2 =   626.758

d = 25.03 mm

The outer diameter of the spacers that yields the most economical and safe design is 25.03 mm

5 0
3 years ago
Does anybody know how to take a screenshot on a HP pavilion computer?
Setler79 [48]

Answer:

I do i do it everyday

Explanation:

Press windows and prt sc at the same time

6 0
2 years ago
Other questions:
  • A cylindrical bar of steel 10.1 mm (0.3976 in.) in diameter is to be deformed elastically by application of a force along the ba
    15·1 answer
  • In case of damaged prestressed concrete I girders which are used for restoring strength?
    9·1 answer
  • Different types of steels contain different elements that alter the characteristics of the steel. For each of the following elem
    6·1 answer
  • Which of the following best describes a central idea of the text?
    10·1 answer
  • 14. The top plate of the bearing partition
    8·1 answer
  • How to solve circuit theory using mesh analysis<br>​
    11·1 answer
  • Multimeter and the LCD is showing Hz. What's she measuring?
    11·1 answer
  • If the same type of thermoplastic polymer is being tensile tested and the strain rate is increased, it will: g
    14·1 answer
  • Witch one is cuter compared to ur opinion calico kitten or grey?​
    5·1 answer
  • Match the use of the magnetic field to its respective description.​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!