![subject](/tpl/images/cats/informatica.png)
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);
}
![ansver](/tpl/images/cats/User.png)
Answers: 2
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 06:00
What makes myhexadecimalnumber a child of mynumber? which methods does myhexadecimalnumber inherit directly from the mynumber class? what can an instance of the mynumber class do? what can an instance of the myhexadecimalnumber class do? which methods are overridden? why are they overridden? how many examples of overloading are there? why was this done? where is the super keyword used? what is it doing? why isn’t the incoming value set immediately in the second myhexadecimalnumber constructor? how many examples can you find of an inherited method being called?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 22:30
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 04:30
What is the process in which the software development team compiles information to determine the final product
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](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 19:50
![question](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 19:50
![question](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 19:50
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/istoriya.png)
History, 02.11.2020 19:50
![question](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 19:50
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/fizika.png)
Physics, 02.11.2020 19:50
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 02.11.2020 19:50
![question](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 19:50
![question](/tpl/images/cats/en.png)
English, 02.11.2020 19:50
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/fizika.png)
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 19:50
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 02.11.2020 20:00