Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What kind of loop is for (;;)?

Found in torvalds/linux-2.6.git -> kernel/mutex.c line 171

I have tried to find it on Google and such to no avail.

What does for (;;) instruct?

like image 256
user242294 Avatar asked Jan 02 '10 14:01

user242294


People also ask

What are the 3 types of loops?

The three types of loop control statements are: break statement. continue statement. pass statement.

What are the 2 types of loop?

A Loop is used to repeat a specific block of code a over and over. There are two main types of loops, for loops and while loops.


2 Answers

It literally means "do nothing, until nothing happens and at each step, do nothing to prepare for the next". Basically, it's an infinite loop that you'll have to break somehow from within using a break, return or goto statement.

like image 177
Blindy Avatar answered Sep 24 '22 10:09

Blindy


The for(;;) is an infinite loop condition, similar to while(1) as most have already mentioned. You would more often see this, in kernel mutex codes, or mutex eg problem such as dining philosophers. Until the mutex variable is set to a particular value, such that a second process gets access to the resource, the second process keeps on looping, also known as busy wait. Access to a resource can be disk access, for which 2 process are competing to gain access using a mutex such that at a time only one process has the access to the resource.

like image 21
Abhijit K Rao Avatar answered Sep 22 '22 10:09

Abhijit K Rao