Answer:
Explanation:
Following are the Semaphores:
Customers: Counts waiting customers;
Barbers: Number of idle barbers (0 or 1)
mutex: Used for mutual exclusion.
Cutting: Ensures that the barber won’t cut another customer’s hair before the previous customer leaves
Shared data variable:
count_cust: Counts waiting customers. ------------copy of customers. As value of semaphores can’t access directly.
// shared data
semaphore customers = 0; semaphore barbers = 0; semaphore cutting = 0; semaphore mutex = 1;
int count_cust= 0;
void barber() {
while(true) { //shop is always open
wait(customers); //sleep when there are no waiting customers
wait(mutex); //mutex for accessing customers1
count_cust= count_cust-1; //customer left
signal(barbers);
signal(mutex);
cut_hair();
}
}
void customer() {
wait(mutex); //mutex for accessing count_cust
if (count_cust< n) {
count_cust= count_cust+1; //new customer
signal(customers); signal(mutex);
wait(barbers); //wait for available barbers get_haircut();
}
else { //do nothing (leave) when all chairs are used. signal(mutex);
}
}
cut_hair(){ waiting(cutting);
}
get_haircut(){
get hair cut for some time; signal(cutting);
}
Trusting, loyal, and a hard worker. All indristies want employees who won't backstab, works hard, and is loyal to the company
Answer:
import random
def simulate_observations():
#this generates an array of 7 numbers
#between 0 and 99 and returns the array
observations = random.sample(range(0, 100), 7)
return observations
#here,we call the function created above and print it
test_array = simulate_observations()
print(str(test_array))
Answer:
n = int(input("Enter the n (positive odd integer): "))
for i in range(1, n+1, 2):
print(i*"*")
for i in range(n-2, 0, -2):
print(i*"*")
Explanation:
*The code is in Python.
Ask the user to enter the n
Create a for loop that iterates from 1 to n, incrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration
Create another for loop that iterates from n-2 to 1, decrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration
Msconfig is what u would enter to launch system configuration