Synchronization using Semaphores
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
:-D Sounds like a fun homework assignment! Be sure to post your finished project as an article here so that we all can learn from it.;) "If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
Just leave the missionaries with the cannibals and maybe we'll all have a better life without all these god botherers. Old Simon HB9DRV
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
What I love about these homework assignments is that they're so subject to interpretation it's impossible to figure out. Take "Missionary_Arrived". Now, this method appears to do several things: 1. responsible for synchronization 2. arrange arriving missionaries 3. and these procedures (Missionary_Arrived and Cannibal_Arrived) arrange arriving missionaries and cannibals into safe boatloads Now, I ask you, does arriving missionaries mean arriving at the departure boat or arriving at the other side of the river? I'm sooo confused!!! Then it says: toni kukuoc wrote: Then a new boat arrives Is this an empty boat, ready to take on missionaries and cannibals, or is this a boat full of said people? And exactly how many boats are on this river??? Since there's no upper limit on the number of cannibals and missionaries, eventually it seems that the river would get choked up with boats!!! Certainly the instructions give NO CLUE as to how boats depart. Only arrive. So, in the end, the missionaries and cannibals should just be able to walk across the river, going from boat to boat. But to figure this out, we need to know more information about the river, it's width, the current, the size of each boat, etc. These are not input parameters! And finally: toni kukuoc wrote: If there are any persons left at the end of your program, they must be reported. How dumb is that! The parameters are clear: (M+A)/3 must not have a remainder. And each boat must be full. IT'S IMPOSSIBLE TO HAVE PERSONS LEFT AT THE END OF THE PROGRAM!!! Who should they be reported to? The missing person's bureau? The only way I figure there can be persons left at the end is if the missionaries succeed in converting some of the cannibals to missionaries while waiting for a boat! Gads, with idiotic assignments like this that make no sense, no wonder I couldn't deal with programming classes. Marc MyXaml Advanced Unit Testing
-
What I love about these homework assignments is that they're so subject to interpretation it's impossible to figure out. Take "Missionary_Arrived". Now, this method appears to do several things: 1. responsible for synchronization 2. arrange arriving missionaries 3. and these procedures (Missionary_Arrived and Cannibal_Arrived) arrange arriving missionaries and cannibals into safe boatloads Now, I ask you, does arriving missionaries mean arriving at the departure boat or arriving at the other side of the river? I'm sooo confused!!! Then it says: toni kukuoc wrote: Then a new boat arrives Is this an empty boat, ready to take on missionaries and cannibals, or is this a boat full of said people? And exactly how many boats are on this river??? Since there's no upper limit on the number of cannibals and missionaries, eventually it seems that the river would get choked up with boats!!! Certainly the instructions give NO CLUE as to how boats depart. Only arrive. So, in the end, the missionaries and cannibals should just be able to walk across the river, going from boat to boat. But to figure this out, we need to know more information about the river, it's width, the current, the size of each boat, etc. These are not input parameters! And finally: toni kukuoc wrote: If there are any persons left at the end of your program, they must be reported. How dumb is that! The parameters are clear: (M+A)/3 must not have a remainder. And each boat must be full. IT'S IMPOSSIBLE TO HAVE PERSONS LEFT AT THE END OF THE PROGRAM!!! Who should they be reported to? The missing person's bureau? The only way I figure there can be persons left at the end is if the missionaries succeed in converting some of the cannibals to missionaries while waiting for a boat! Gads, with idiotic assignments like this that make no sense, no wonder I couldn't deal with programming classes. Marc MyXaml Advanced Unit Testing
My programming teacher was useless in other ways. He'd set the most basic assignments, then come and ask me how I'd done them ( I'd be playing Star Trek by the time he finished explaining it ), because he had no idea. I dropped out of that course. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
toni kukuoc wrote: In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Can we reverse the cultural bias against cannibals by changing the above statement to: "In order to guarantee the culture of the cannibals, you cannot put one cannibal and two missionaries into the same boat (because missionaries would gang up and convert that single cannibal), but all other combinations are legal"? ;P
-
A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river but it only seats three people and must always carry a full load. In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Your program will first ask the number of missionaries and cannibals. The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three. First, you should create processes for each cannibal and missionaries. They will walk to the river bank for a while (arrival times are random, you can use sleep call here). Two procedures are needed, Missionary_Arrived and Cannibal_Arrived called by missionary or cannibal processes when they arrive the river bank. These procedures are responsible for synchronization. And these procedures arrange arriving missionaries and cannibals into safe boatloads. Once the boat is full, one process calls Raw_Boat and after calling Row_Boat, the three procedures then return. Then a new boat arrives. There should also be no undue waiting; that is missionaries and cannibals should not wait if there are enough of them for a safe boatload. Your program should display how a boat is arranged each time and who is on the boat. If there are any persons left at the end of your program, they must be reported. Remember that, all the synchronization operations should be mutually exclusive. You must use UNIX semaphores to enable synchronization. codingggggggggggggggggggg
-
toni kukuoc wrote: In order to guarantee the safety of the missionaries, you can not put one missionary and two cannibals into the same boat (because cannibals would gang up and eat that single missionary), but all other combinations are legal. Can we reverse the cultural bias against cannibals by changing the above statement to: "In order to guarantee the culture of the cannibals, you cannot put one cannibal and two missionaries into the same boat (because missionaries would gang up and convert that single cannibal), but all other combinations are legal"? ;P
Will two Missionaries be enough for a Cannibal :confused:
Stuck to Programming through an unbreakable bond :( My Articles
-
Josh Gray wrote: im sure you will need a method called Missionary_Position somewhere in there ah beying ma ung;P Mine is not to question Why, but to shake my head and sigh.:sigh:
-
What I love about these homework assignments is that they're so subject to interpretation it's impossible to figure out. Take "Missionary_Arrived". Now, this method appears to do several things: 1. responsible for synchronization 2. arrange arriving missionaries 3. and these procedures (Missionary_Arrived and Cannibal_Arrived) arrange arriving missionaries and cannibals into safe boatloads Now, I ask you, does arriving missionaries mean arriving at the departure boat or arriving at the other side of the river? I'm sooo confused!!! Then it says: toni kukuoc wrote: Then a new boat arrives Is this an empty boat, ready to take on missionaries and cannibals, or is this a boat full of said people? And exactly how many boats are on this river??? Since there's no upper limit on the number of cannibals and missionaries, eventually it seems that the river would get choked up with boats!!! Certainly the instructions give NO CLUE as to how boats depart. Only arrive. So, in the end, the missionaries and cannibals should just be able to walk across the river, going from boat to boat. But to figure this out, we need to know more information about the river, it's width, the current, the size of each boat, etc. These are not input parameters! And finally: toni kukuoc wrote: If there are any persons left at the end of your program, they must be reported. How dumb is that! The parameters are clear: (M+A)/3 must not have a remainder. And each boat must be full. IT'S IMPOSSIBLE TO HAVE PERSONS LEFT AT THE END OF THE PROGRAM!!! Who should they be reported to? The missing person's bureau? The only way I figure there can be persons left at the end is if the missionaries succeed in converting some of the cannibals to missionaries while waiting for a boat! Gads, with idiotic assignments like this that make no sense, no wonder I couldn't deal with programming classes. Marc MyXaml Advanced Unit Testing
You wrote: Now, I ask you, does arriving missionaries mean arriving at the departure boat or arriving at the other side of the river? I'm sooo confused!!! arriving at the departure boat You wrote: Is this an empty boat, ready to take on missionaries and cannibals, or is this a boat full of said people? yes this is empty boat and ready to take on missionaries and cannibals. You wrote: And exactly how many boats are on this river??? only one boat and/or two boat it is ur decision. You wrote: Since there's no upper limit on the number of cannibals and missionaries The number of cannibals must be greater than one, and the number of missionaries must be greater than two, finally the total number of persons should be multiples of three.ex:3 6 9 12 30 60 90 120 150 .....may be finally 210.ur choice You wrote: Certainly the instructions give NO CLUE as to how boats depart. Only arrive. So, in the end, the missionaries and cannibals should just be able to walk across the river, going from boat to boat. But to figure this out, we need to know more information about the river, it's width, the current, the size of each boat, etc. These are not input parameters! these ar not important.across the river 3 to 3 is important thing.others are not important. You wrote: How dumb is that! The parameters are clear: (M+A)/3 must not have a remainder. And each boat must be full. IT'S IMPOSSIBLE TO HAVE PERSONS LEFT AT THE END OF THE PROGRAM!!! at the end of the program you can print all missionaries and cannibals across the river. You wrote: Who should they be reported to? The missing person's bureau? The only way I figure there can be persons left at the end is if the missionaries succeed in converting some of the cannibals to missionaries while waiting for a boat! this is not important again. if you can do this homework with C, i am thanked you Thanks a lot:confused::confused: codingggggggggggggggggggg