Let's say that, instead philosophers, we have TCP/IP connections to a server, and instead forks we have the server's TCP/IP avaliable ports. In this scenario, we don't have a lot of connections competing for the ports: we have a few number of malicious connections that will take a lot of time to process, so they will take the awaliable ports and release them after a long time (from some minutes to several hours). In this scenario, actual non-attacking connections will starve.In this case, the analogy would be:avaliable ports: forks non attacking connections: philosophers that spend more time thinking than eatingattacking or malicious connections: philosophers that spend a lot more time eating thanthinking.If we ignore the case when every philosopher takes one fork (they deadlock eachother), I consider Dining-Philosophers an example for resource starvation, because if there are no avaliable shared resources, the threads will wait (maybe forever) until a resource is released by another thread.
is a DoS attack a good analogy of Dining Philosophers?
concurrency;analogy
The more I think about this analogy the less sense it makes.Ports don't work as a resource here. A server will have only a handful of ports open, perhaps only one (say, port 80 for HTTP). Any number of clients can connect to this and their connections are differentiated by the client port ID (and client IP), which are independent for each client. Port numbers aren't the limited resource that's attacked by DoS attacks, network bandwidth or CPU time or similar things are.Although network bandwidth and CPU time are, in the end, an integer amount (in the appropriate unit), it is not meaningful to identify these units with forks. Clock cycles or bandwidth is interchangeable, while forks have identity, and the analogy becomes absurd when each philosopher needs 5 million forks. Furthermore, now a philosopher can take, say, one clock cycle and hold onto it for a minute, which is at least more abstract and makes philosopher-time meaningless.The philosophers have spatial arrangement and choose from the forks around them. In contrast, any reasonable notion of resource in your analogy will not be constrained like this: Any client can get any resource, probably at the discretion of the server rather than by choice of the client.As you note, there is no potential for deadlocks. The dining philosophers is more about deadlocks (and livelocks) than starvation, though I'm certain some discussion of fairness can be found. Resource starvation is typically discussed with other examples.