subject

The goal of this assignment is to become familiar with semaphores in POSIX-based operating systems. You may have noticed that your fish’s swim mill might have acted a bit erratic! Your assignment is to modify the swim mill that you created with Assignment #3 to include a semaphore to control access to critical resources. Make sure that you have signal handing to terminate all processes, if needed. In case of abnormal termination, make sure to remove shared memory and semaphores as well. Use semget(2), semctl(2), and semop(2) to implement the semaphore. Your semaphore should receive the names of functions passed as parameters. Since different functions are required to access the critical resource, passing the functions as parameters will prove a clean option. The original assignment was to make a fishmill with a coordinator. c, fish. c, and pellet. c. The pellets are created in a shared memory 2d array and fall down towards the fish. The fish can only move left or right in the bottom row. When the fish and a pellet are in the same location, the fish eats the pellet and then moves towards the next pellet.
coordinator. c
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
void interrupt();
void onAlarm();
void onAbort();
int main(int argc, char *argv[]) {
signal(SIGINT, interrupt);
signal(SIGALRM, onAlarm);
signal(SIGABRT, onAbort);
alarm(30);
int processes = 0;
int smID;
key_t key = 1337;
char (*stream)[10][10];
//Create the shared mememory segment
if ((smID = shmget(key, sizeof(char[10][10]), IPC_CREAT | 0666)) < 0) {
perror("Could not create the memory segment\n");
exit(1);
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:30
Corey set up his presentation for delivery to his team.the information he had to convey was critical to their job performance.he knew he would need a lot of time to explain each point
Answers: 3
question
Computers and Technology, 23.06.2019 18:20
What is wi-fi infrastructure? a metropolitan area network that uses radio signals to transmit and receive data a communications technology aimed at providing high-speed wireless data over metropolitan area networks a means by which portable devices can connect wirelessly to a local area network, using access points that send and receive data via radio waves includes the inner workings of a wi-fi service or utility, including the signal transmitters, towers, or poles and additional equipment required to send out a wi-fi signal
Answers: 2
question
Computers and Technology, 23.06.2019 21:30
Which of the following includes the three primary network access technologies? dsl, cable modem, broadband lan, wan, man voip, uc, iptv tcp/ip, ftp, dhcp
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
You know the right answer?
The goal of this assignment is to become familiar with semaphores in POSIX-based operating systems....
Questions
question
Arts, 15.09.2021 15:40
question
History, 15.09.2021 15:40