Question
I need some help fixing these error , they are driving me crazy the program is in C, and has these errors ------what program should
I need some help fixing these error , they are driving me crazy the program is in C, and has these errors
------what program should do----
Option-B (10 pts): Write a Pthreads program 'Dining-Philosophers.c' to implement the classical 'Dining-Philosophers' problem by using Pthreads mutex locks and condition variables. To implement the program, please follow the hints below.
(a) The detailed 'Dining-Philosophers' problem statement: Refer to Page 71 ~ Page 72 in 'Lecture-08.pptx'
(b) The introduction to Pthreads mutex locks and condition variables: Refer to Page 17 ~ Page 39 in 'Lecture-08.pptx'
(c) Creating five philosophers, each of which will run as a separate thread. Philosophers alternate between thinking and eating:
The activities of thinking and eating can be simulated by having the thread sleep for a random period between one and three seconds.
When a philosopher wishes to eat, he/she invokes the function: Pickup_Forks (int Philosopher_ID)
When a philosopher finishes eating, he/she invokes the function: Return_Forks (int Philosopher_ID)
There are many possible output sequences. Here is one possible output sequence.
Note: I place the output sequence into two columns, actually the five on the left column should be placed before the rest five on the right column.
./Dining-Philosophers
Philosopher 0 is eating | Philosopher 1 is eating |
Philosopher 2 is eating | Philosopher 1 is thinking |
Philosopher 2 is thinking | Philosopher 3 is thinking |
Philosopher 3 is eating | Philosopher 4 is eating |
Philosopher 0 is thinking | Philosopher 4 is thinking
|
-----------errors ------- prog.c: In function 'main': prog.c:53:54: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] pthread_create( &philosophers[i], NULL, philosopher, (void*)i); ^ prog.c:53:41: warning: passing argument 3 of 'pthread_create' from incompatible pointer type [-Wincompatible-pointer-types] pthread_create( &philosophers[i], NULL, philosopher, (void*)i); ^ In file included from prog.c:2:0: /usr/include/pthread.h:233:12: note: expected 'void * (*)(void *)' but argument is of type 'void (*)(int)' extern int pthread_create (pthread_t *__restrict __newthread, ^ /tmp/ccwnzH68.o: In function `main': 53b5b6a8283c35b36cc9c164e53d178e.c:(.text+0x23d): undefined reference to `pthread_create' 53b5b6a8283c35b36cc9c164e53d178e.c:(.text+0x26a): undefined reference to `pthread_join' collect2: error: ld returned 1 exit status
----------- code below---------
#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started