Lab4Assignmnet23

pdf

School

McMaster University *

*We aren’t endorsed by this school

Course

3SH3

Subject

Philosophy

Date

Jan 9, 2024

Type

pdf

Pages

2

Uploaded by puyuehaha

Report
COMPSCI 3SH3 Fall, 2023 November 2, 2023 Lab report due date: Nov. 19th 2023, 11:59:59 pm Lab 4: Practice and Assignment - Synchronization The implementation has to be completed during lab time. You can present your assignment to TA in any of four lab sessions. a) Show your solution to TA and run it on Linux VM b) Answer all questions related to the implementation details Practice Time 1. Familiarize yourself with POSIX synchronization methods presented in section 7.3 POSIX Mutex Locks POSIX Semaphores POSIX Condition Variables 2. Read the section 7.1.3 The Dining-Philosophers Problem. Assignment Question 1. The Dining-Philosophers Problem Implement a solution to dining-philosopher problem using POSIX mutex locks. Create five philosophers, each identified by a number 0..4. Each philosopher will run as a separate thread. Philosophers alternate between thinking and eating. To simulate both activities, have each thread sleep
COMPSCI 3SH3 Lab Assignment 4 Page 2 of 2 for a random period between one and three seconds. When a philosopher wishes to eat, she invokes the function pickup forks(int philosopher number) where philosopher number identifies the number of the philosopher wish- ing to eat. When a philosopher finishes eating, she invokes return forks(int philosopher number) Your implementation will require the use of POSIX condition variables.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help