I'll take the lower block to be sliding to the right.
Things to note:
1. We want the upper block to be
on the point of slipping. If it's not on the point of slipping, then the horizontal force being applied to the lower block is not large enough. We want the maximum force, so the upper block will be just about to start slipping. So the friction force acting on the upper block is

. It acts to the RIGHT since the block is on the point of slipping to the left (relative to the bottom block).
2. Both blocks have the same acceleration
a because the upper block is not slipping. If it
was slipping the acclerations of each block would be different.
3. It always helps to draw a diagram showing
all the forces acting on all the objects ....
The 1 kg block has three forces acting on it in the
vertical direction: Weight force = (1)(g) = g (down), normal reaction force

(up) from the ground, normal reaction force

(down) from contact with the bottom of the 0.5 kg mass.
The 1 kg block has two forces acting on it in the
horizontal direction: Pulling force P (to the right, say), friction force

since the block is sliding (the force acts to the left).
The 0.5 kg block has two forces acting on it in the
vertical direction: Weight force = (0.5)(g) = g/2 (down), normal reaction force

(up) from contact with the top of the 1 kg block.
The 0.5 kg block has one force acting on it in the
horizontal direction: friction force

since the block is
on the point of sliding (this force acts to the RIGHT since the block is on the point of slipping to the left).
4. After considering and doing all of the above you shuold be able to get the following equations:
1 kg block - horizontal direction:

.... (1)
1 kg block - vertcial direction:

.... (2)
0.5 kg block - horizontal direction:

.... (3)
0.5 kg block - vertical direction:

. .... (4)
There are four equations and four unknowns, including P. Solve these four equations simultaneously and you'll get P.