Dining philosophers C program

Feb 3rd, 2012
Studypool Tutor
Price: $10 USD

Tutor description

It is a C program of the dining philosophers problem. It is done using threads and semaphores. It also makes use of various semaphore functions: wait and post.I did this for my university lab.

Word Count: 252
Showing Page: 1/2
PROGRAM DEVELOPMENT#include#include#include #define N 5#define THINKING 0#define HUNGRY 1#define EATING 2#define LEFT (ph_num+4)%N#define RIGHT (ph_num+1)%N sem_t mutex;sem_t S[N]; void * philospher(void *num);void take_fork(int);void put_fork(int);void test(int); int state[N];int phil_num[N]={0,1,2,3,4}; int main(){ int i; pthread_t thread_id[N]; sem_init(&mutex,0,1); for(i=0;i

Review from student

Studypool Student
" Excellent work as always thanks so much "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1824 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors