Theoretical analysis of two-gap superconductivity of magnesium diborades and iron pnictides in the generalized α model