|
Re: فكر: الحلاق والفلاسفة الخمسة. (Re: Biraima M Adam)
|
Dining philosophers problem From Wikipedia, the free encyclopedia
In computer science, the dining philosophers problem is an illustrative example of a common computing problem in concurrency. It is a classic multi-process synchronization problem, and is included in nearly all college-level computer science curricula In 1971, Edsger Dijkstra set an examination question on a synchronization problem where five computers competed for access to five shared tape drive peripherals. Soon afterwards the problem was retold by Tony Hoare as the dining philosophers problem
The dining philosophers problem is summarized as five philosophers sitting at a table doing one of two things - eating or thinking. While eating, they are not thinking, and while thinking, they are not eating. The five philosophers sit at a circular table with a large bowl of spaghetti in the center. A fork is placed in between each philosopher, and as such, each philosopher has one fork to his or her left and one fork to his or her right. As spaghetti is difficult to serve and eat with a single fork, it must be assumed that in order for a philosopher to eat, the philosopher must have two forks. In the case of the dining philosopher, the philosopher can only use the fork on his or her left or right
Illustration of the dining philosophers problemIn some cases, the dining philosophers problem is explained using rice and chopsticks as opposed to spaghetti and forks, as it is generally easier to understand that two chopsticks are required, whereas one could arguably eat spaghetti using a single fork. In either case, only one instrument (fork or chopstick) can be picked up at a time, and the philosopher must have two instruments in order to eat
The philosophers never speak to each other which creates a dangerous possibility of deadlock in which every philosopher holds a left fork and waits perpetually for a right fork (or vice versa)
Originally used as a means of illustrating the problem of deadlock, this system reaches deadlock when there is a 'cycle of ungranted requests'. In this case philosopher P1 waits for the fork grabbed by philosopher P2 who is waiting for the fork of philosopher P3 and so forth, making a circular chain
Starvation (and the pun was intended in the original problem description) might also occur independently of deadlock if a philosopher is unable to acquire both forks due to a timing issue. For example there might be a rule that the philosophers put down a fork after waiting five minutes for the other fork to become available and wait a further five minutes before making their next attempt. This scheme eliminates the possibility of deadlock (the system can always advance to a different state) but still suffers from the problem of livelock. If all five philosophers appear in the dining room at exactly the same time and each picks up their left fork at the same time the philosophers will wait five minutes until they all put their forks down and then wait a further five minutes before they all pick them up again
The lack of available forks is an analogy to the locking of shared resources in real computer programming, a situation known as concurrency. Locking a resource is a common technique to ensure the resource is accessed by only one program or chunk of code at a time. When the resource the program is interested in is already locked by another one, the program waits until it is unlocked. When several programs are involved in locking resources, deadlock might happen, depending on the circumstances. For example, one program needs two files to process. When two such programs lock one file each, both programs wait for the other one to unlock the other file, which will never happen
بريمة
|
|
|
|
|
|
|
العنوان |
الكاتب |
Date |
فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-26-07, 02:21 AM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-26-07, 04:12 AM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-26-07, 06:22 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Abuelgassim Gor | 04-26-07, 06:39 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 12:10 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 05:40 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 07:32 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 07:40 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 07:55 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 08:22 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 09:12 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 09:24 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-27-07, 09:36 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Fadl Karrar | 04-27-07, 11:19 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-28-07, 02:09 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Fadl Karrar | 04-28-07, 06:53 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-28-07, 07:30 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Fadl Karrar | 04-28-07, 08:03 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Fadl Karrar | 04-29-07, 01:07 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Biraima M Adam | 04-29-07, 01:14 PM |
Re: فكر: الحلاق والفلاسفة الخمسة. | Fadl Karrar | 04-29-07, 02:12 PM |
|
|
|