Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(15) In William Golding's book, The Lord of the Flies, a group of school-age boys is stranded on an island. In order to organize themselves

image text in transcribed

(15) In William Golding's book, The Lord of the Flies, a group of school-age boys is stranded on an island. In order to organize themselves and maintain order they make a rule about their meetings: only the boy holding the conch shell is allowed to speak. Write some code to model this process using semaphores and the C-like syntax used for semaphore examples in class and in Tanenbaum and Woodhull. Assume each boy is an independent process. Assume for the purposes of this problem there are N boys arranged in a circle, that N is a constant, and that numbers increment in the clockwise direction. You may also assume that each boy has something to say, and when a boy is finished talking he passes the conch to his left. Write three functions to manage the meeting: start_talking(int i) called by boy i when he wants to speak. stop talking (int i) called by boy i when he is done speaking. init() called before anybody tries to speak. Thus, the boy() function would look something like: void boy(int self) { for(;;) { start_talking(self); /* spout nonsense */ stop talking(self); /* shaddup *7 } } Explain briefly how your solution models the process of passing the shell and label any shared data. Think carefully, then write? Solutions will be graded both for correctness and quality. (15) In William Golding's book, The Lord of the Flies, a group of school-age boys is stranded on an island. In order to organize themselves and maintain order they make a rule about their meetings: only the boy holding the conch shell is allowed to speak. Write some code to model this process using semaphores and the C-like syntax used for semaphore examples in class and in Tanenbaum and Woodhull. Assume each boy is an independent process. Assume for the purposes of this problem there are N boys arranged in a circle, that N is a constant, and that numbers increment in the clockwise direction. You may also assume that each boy has something to say, and when a boy is finished talking he passes the conch to his left. Write three functions to manage the meeting: start_talking(int i) called by boy i when he wants to speak. stop talking (int i) called by boy i when he is done speaking. init() called before anybody tries to speak. Thus, the boy() function would look something like: void boy(int self) { for(;;) { start_talking(self); /* spout nonsense */ stop talking(self); /* shaddup *7 } } Explain briefly how your solution models the process of passing the shell and label any shared data. Think carefully, then write? Solutions will be graded both for correctness and quality

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions