Boil spaghetti in salted water as per package instructions until al dente. Reserve a cup of pasta water before you drain the pasta.
While the spaghetti is boiling, heat a tablespoon of olive oil in a pan and add mushrooms. Saute on medium high heat for a few minutes till golden brown on all sides.
In the same pan, add the remaining olive oil and garlic. On a low heat, cook the garlic for a few minutes till a light golden brown. Add chilli flakes and the reserved pasta water, half teaspoon salt and let this cook and reduce till the sauce emulsifies (about 2-3 minutes).
Add the cooked spaghetti, mushrooms, parsley and toss well till the sauce coats the pasta. Top with grated parmesan and serve
Always add the pasta to boiling water. Never add pasta to warm or room temperature water. Time it and cook it till al dente.
Reserve some of the pasta water as the starch present in this will help thicken the sauce.
Cook mushroom on medium high heat instead of low heat. Slow cooking tends to make the mushroom limp and leave out water. Do not overcook.
Time it so that the spaghetti gets cooked just about the same time the sautéed mushroom aglio olio is ready. This way the spaghetti won't harden and the mushrooms won't leave out water.