As systems become increasingly autonomous, synchronization b…

Questions

As systems becоme increаsingly аutоnоmous, synchronizаtion becomes increasingly important. Consider a charging facility for self-driving cars with 10 charging stations, each of which can accommodate only one car. Use pseudocode to answer the following questions. (a) [10pts] Use a semaphore to synchronize the cars and ensure that no more than 10 cars use the charging stations at the same time. (b) [10pts] To improve traffic flow, the facility adds 20 parking spaces for cars waiting to charge. Each arriving car must reserve a parking space before waiting for a charging station and releases the parking space when it moves to a charging station. If all 20 parking spaces are occupied, additional cars must wait outside the facility. Use semaphores to ensure that the capacities of both the charging area and the parking area are not exceeded. (c) [10pts] The facility changes its policy to reduce waiting time. If all 20 parking spaces are occupied, an arriving car immediately leaves and travels to another charging facility rather than waiting outside. Hint: Because the semaphore operation wait() is blocking, use a shared counter to track the number of available parking spaces. Clearly label your answer to each subquestion. Unlabeled answers may not receive credit.