BTW, the case statements in your 'switch(pid)' are incorrect. 0 is returned by fork() in the parent process (which you have correct), but it will almost certainly never return 1 for the child process. So proc_val will never be 1 and loop_2() will never run.
Might wanna try something like this instead:
Code:
pid = fork();
proc_val = pid?1:0;
if(proc_val)
loop_2();
else
loop_1();