Cognitive function and the performance of a secondary, dual task may affect certain aspects of gait, but the relationships between cognitive function and gait are not well understood. To better understand the motor control of gait and the relationship between cognitive function and gait, we studied cognitive function and the effects of different types of dual tasking on the gait of patients with Parkinson's disease (PD) and controls, contrasting measures of gait automaticity and rhythmicity with other features. Patients with idiopathic PD (n=30; mean age 71.8 year) with moderate disease severity (Hoehn and Yahr Stage 2--3) were compared to age and gender-matched healthy controls (n=28). Memory and executive function were also assessed. In both groups, gait speed decreased in response to dual tasking, in a parallel fashion. For the PD group only, gait variability increased compared to usual walking. Executive function was significantly worse in the PD group, while memory was not different in the two groups. Executive function measures were significantly correlated with gait variability during dual tasking, but not during usual walking. These findings demonstrate that regulation of gait variability and rhythmicity is apparently an automatic process that does not demand attention in healthy adults. In patients with PD, however, this ability becomes attention-demanding and worsens when subjects perform secondary tasks. Moreover, the associations between executive function and gait variability suggest that a decline in executive function in PD may exacerbate the effects of dual tasking on gait, potentially increasing fall risk.