-1
$\begingroup$

Theoretically, is there a way to measure how many infinite loops are running at a given point in time? In other words, is there a way to freeze everything and get a number on how many infinite lines of code are running on every machine.

$\endgroup$
  • $\begingroup$ I'm not sure how to make sense of this question. $\endgroup$ – Yuval Filmus Oct 5 '18 at 7:27
  • $\begingroup$ Maybe I worded it wrong. When you execute a program, some type of loop runs right? I was wondering if there is a way to basically see how many programs are running at once across all devices connected to the internet. I am sure it is in the trillions but I was just curious. $\endgroup$ – Cody Rutscher Oct 5 '18 at 8:52
  • $\begingroup$ @CodyRutscher Your question asks how many infinite loops; your comment asks about number of running programs. Those are two completely different things. Neither of them seems to be a question about computer science. This seems to be something of a trend with your questions: they attract a lot of down votes and close votes because they're very unclear and don't seem to be on-topic. Please have a look at the help center for information on how to ask better questions. $\endgroup$ – David Richerby Oct 5 '18 at 10:30
0
$\begingroup$

While I don't think your question is fitting for cs.StackExchange, let me try to answer it anyway:

You would approach this problem as follows:

  1. To answer how many infinite loops run on all devices, you would need to determine the number of infinite loop on each device
  2. To determine the number of infinite loops on each device, you would have to count all loops running on each device and then determine if they will be running forever
  3. The last step would require a method that determines for a given loop if it will run forever. Assuming you had such a method, you could do the following:

    a.) Take any piece of code, $\Pi$

    b.) Put it into a loop of the form: "$\text{do} \{\ \Pi\ \}\ \text{while}\ (false);$" As the resulting expression is a loop, you could feed it to your loop-decision method to find out if it terminates.

    c.) The loop will terminate, if and only if $\Pi$ terminates. As you can take any $\Pi$ you want, you would thus be able to solve the Halting problem, which is proven to be impossible.

Thus, it is mathematically impossible to answer your question.

PS: I think the correct label would be computability-theory, not complexity-theory. The latter deals with computations that need a finite time and approaches to derive boundaries for that finite time.

$\endgroup$
  • $\begingroup$ Please. If you think the question is off-topic, don't answer it. If we answer off-topic questions, there's no point having a topic at all. $\endgroup$ – David Richerby Oct 5 '18 at 10:33
  • $\begingroup$ I have the impression that my answer answers the question and that my answer is more or less the standard procedure for a computability proof, a topic related to CS. If I had to guess, I would assume that a person with no prior knowledge/child would formulate a question like this when exposed to some basic computability theory. So I thought I'd include some pointers to relevant wiki articles for getting acquainted. $\endgroup$ – oerpli Oct 5 '18 at 10:43
  • $\begingroup$ I certainly agree that your answer contains computer science. :-) $\endgroup$ – David Richerby Oct 5 '18 at 12:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.