Computers and Technology
Computers and Technology, 08.07.2020 07:01, hvbrown28

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);
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 07:00, Dvrsug8598
You need a quick answer from a coworker. the most effective way to reach your coworker is through a. cloud server b. instant message c. teleconference d. telepresence
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, emmaishere69
List 3 items that were on kens resume that should have been excluded
Answers: 1
image
Computers and Technology, 24.06.2019 18:30, kristine2424
Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
Answers: 1
image
Computers and Technology, 25.06.2019 00:00, bestdiva2
What function key is used to enable the spelling and grammar function
Answers: 1
Do you know the correct answer?
The goal of this assignment is to become familiar with semaphores in POSIX-based operating systems....

Questions in other subjects:

Konu
Mathematics, 09.06.2021 01:20
Konu
Biology, 09.06.2021 01:20
Konu
Mathematics, 09.06.2021 01:20