Firstly, ask yourself, which direction are the masses going to accelerate in? Since they're both hanging vertically (and there is no external torque on the peg), the heavier mass will accelerate downwards and the lighter mass will accelerate upwards. So if we look at the 3kg mass we have the weight force acting downwards, and the tension force

acting upwards. The sum of these (taking into account direction) will give the net force, i.e.

. Since the object is accelerating downwards, the weight force is larger, so for the 3 kg mass we will take down as positive. So we have


Now for the 1 kg mass, we have the weight force acting downwards and the tension force acting upwards, and since it is accelerating upwards we will take up as positive.



The problem that a few people have is that they put the

the wrong way around, as they don't define directions as positive, and just take both up as positive. This actually results in a different system. By making sure you have the larger "mg" or "T" first, then you keep your acceleration

positive, and account for directions. (You could also flip both, but that would be redundant).
Easiest way to solve these is normally solve for

or

and then substitute into the other equation.
Solving:
 & =3a<br />\\ 2g & =4a<br />\\ \implies a & =\frac{1}{2}g\:\:\text{m/s}^{2}<br />\\ \text{Substitute into [2]}<br />\\ T & =\frac{1}{2}g+g<br />\\ \implies T & =\frac{3}{2}g\:\:\text{N}<br />\end{alignedat})