Project and Task User Based

hi all,
I m new to permission how to set the project and user based on user wise.
For EG.,
Project A is allocated to User 1 and User 2.
Project B is Allocated to User 2 and User 3.

Now

User 1 should view project A
User 2 should view project A and project B
User 3 should view project C

Similarly for TASK.
Their assigned task alone should be viewed.
can any one help on this.