To avoid deadlock, I used a possible solution. The odd numbered philosophers grab the right and then the left while even numbered philosophers grap the chopsticks in the reverse order. Implement this solution using pthread mutual exclusion lock.
Please look at my code, although it works,but the print seems wrong.
FOR instance:
philosopher 4 is thinking for 7 seconds
philosopher 4 is eating for 2 seconds
philosopher 3 is no longer eating
but the third sentence should be
"philosopher 4 is no longer eating"
RTM is right about the rules. But this is a tough problem and you have done a lot of work. So I will drop one hint. You are invoking fflush() only some of the time. Invoke it after every printf() or drop it altogether and use "setvbuf(stdout, NULL, _IONBF, 0);" at the beginning of the program.
I love the switch to chopsticks! I have always heard it with forks. It makes sense with chopsticks.
Hi everyone,
I am experiencing discontinuity of Internet service, this started 1 month ago. Everything worked very well for 1 year of intensive use, but now, I have problems reaching my gateway.
The gateway is not my router but a node belonging to my ISP and I share the same public IP with... (3 Replies)
I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore.
Here is what 's happening:
* I wanted to remove lines containing digits so I used this... (25 Replies)
Hi,
This is rather a question from a "user" than from a sys admin, but I think this forum is apropriate for the question.
I have an adress with automatic email forwarding and for some senders (two hietherto), emails are bouncing. This has really created a lot of problems those two time so I... (0 Replies)
Hi.
I`m writng script solving problem of dining philosophers but it does not work.
PHILOSOPHER SRIPT:
#!/bin/bash
./start.conf
cd stol
a=$1
#echo a$a
#echo ilosc$ilosc
#echo dziel$(($%$ilosc))
if ; then
#next=$%$ilosc]
next=1
else
next=$
fi (0 Replies)
Dear ALL.
I installed AIX OS on customer sites.
but Only one site is too slow when I connected telnet, ftp..
Ping is too fast. but telnet and FTP is not connected..
of course i check the configuration file on aix but it's normal.
Do any Idea??
thanks in advance.
- Jun - (3 Replies)
1) when user login to the server the session got colosed. How will resolve?
2) While firing the command ls -l we are not able to see the any files in the director. but over all view the file system using the command df -g it is showing 91% used. what will be the problem?
Thanks in advance. (1 Reply)
Hi
I am right now facing a strange hardware problem. System get booted with the following error:
Fatal Error Reset
CPU 0000.0000.0000.0003 AFSR 0100.0000.0000.0000 SCE
AFAR 0000.07c6.0000.1000
SC Alert: Host System has Reset
It happen 4 or 5 times and get the same error every time.I... (8 Replies)
Hi, folks.
Sorry for bothering, but maybe someone could help me please.
The problem is the following:
there is some script that copies files from local file system to AFS. The copying is performed with dd command.
The script copies data into some AFS volumes.
The problem appeared with one... (0 Replies)
Hi,
Just recently we seem to be getting the following error message relating to SSH when we run the UNIX script in background mode:
warning: You have no controlling tty. Cannot read confirmation.^M
warning: Authentication failed.^M
Disconnected; key exchange or algorithm negotiation... (1 Reply)