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 04:00
When you collaborate or meet with a person or group online, it is called
Answers: 1
question
Computers and Technology, 22.06.2019 18:00
Determine whether the following careers would require training or college.
Answers: 1
question
Computers and Technology, 22.06.2019 22:50
Which is the best minecraft server? a. mineplex b. worldonecraft c. 9b9t d. 2b2t
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
*! 20 points! *jeff wants to create a website with interactive and dynamic content. which programming language will he use? a. dhtml b. html c. css d. javascript
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
Geography, 18.07.2019 04:30
Questions on the website: 13722367