Macken then powered in the winner to lift the Tykes away from the drop zone and leave Posh in trouble.
The home side handed a debut to 19-year-old Manchester United goalkeeper Ben Amos as Joe Lewis served a one-match suspension following his sending-off at Blackburn in the Carling Cup in midweek while striker Craig Mackail-Smith was out with a hamstring injury.
Aaron Mclean should have given the hosts an early lead but headed wide from close range before Amos made his first stop, getting down low to save Hugo Colace's shot.
Ferguson's side were looking dangerous and forged ahead in the 24th minute.
Boyd swung over a corner from the right and Darren Moore was penalised for holding Gabriel Zakuani as he challenged for a header.
Boyd confidently stepped up and rolled the spot-kick past former Peterborough goalkeeper Luke Steele to record his fifth goal in five games.
It was just the start Posh wanted, but they switched off to allow the Tykes to hit a response within 90 seconds.
Former Manchester City forward Macken ambled into space on the right and was allowed the time to pick out Bogdanovic who made no mistake with a poweful header which gave Amos no chance.
Ferguson sent on on-loan Tottenham midfielder Danny Rose to replace the injured Chris Whelpdale but could only watch as Macken fired Barnsley ahead in the 39th minute.
Anderson De Silva picked out Macken inside the area with a precise pass and he lashed the ball high into the roof of the net.
Peterborough midfielder Lee Frecklington curled over from the edge of the area at the start of the second half before Amos pulled off a fine save to keep the game alive.
Adam Hammill whipped in a free-kick from the left and Stephen Foster got in front of his marker to flick a header goalward, but Amos managed to claw the ball to safety where Zakuani completed the clearance.
Zakuani was then replaced, with Ryan Bennett coming on for his debut, before his defensive partner Craig Morgan went close to an equaliser from another Boyd delivery.
Bennett then headed over from inside the six-yard box as Peterborough surged forward in search of an equaliser but Mark Robins' side clung on to the win.