Cook the pasta according to package instructions in a large pot of salted boiling water until al dente. Reserve 1/2 cup of pasta water, then drain the pasta and set aside.
In a large skillet, heat 2 tablespoons of olive oil over medium heat. Add the sliced onions and sprinkle with 1/2 teaspoon of salt. Cook, stirring occasionally, for about 15-20 minutes until the onions are soft and golden brown.
Add the sugar, black pepper, and red pepper flakes to the skillet. Continue cooking for another 5-10 minutes, stirring frequently, until the onions are deeply caramelized.
Add the cooked pasta to the skillet with the caramelized onions. Pour in the reserved pasta water and the remaining tablespoon of olive oil. Toss everything together until well combined. If the pasta seems dry, add a little more pasta water.
Serve the pasta warm, topped with grated Parmesan cheese and garnished with fresh parsley.