How to interface two leds and two push button with 8051?
the while(1) statement only encloses the S1 press handler code. count the curly braces { } and move the S2 handler code inside the set of matching curly braces that belong to the while.

while(1) // forever
{
    // all code goes here
    if(....) 
    {
    }
    if(...)
    {
    }
} // end of while(1)
// anything after this point never runs