Q:

How to call different functions with os.fork() in loop?

I tried using following code
import os

def sum1(a):
    print "We are in the child process with PID= %d"%os.getpid()
    for j in range(100000000): 
        m=j
    print "Sum: ",sum(a)

    os._exit(0)

def mul(a):

    print "We are in the child process with PID= %d"%os.getpid()
    k=1
    for j in range(100000000): 
        m=j
    for i in a:
        k=k*i
    print "Multiplication: ",k

def parent(a):
    while True:
        print "We are in the parent process with PID= %d"%os.getpid()
        newpid=os.fork()

        if newpid == 0:
            sum1(a)

        else:
            mul(a)
        if input() == 'q': break

a=[12,12,12,12]
parent(a)

But here in this code it creates forked process for only one function [ sum1() ] . I want to execute fork process in loop with calling different function each time. For example I want to call below three functions with different forked process in loop
def f1(a):
    print a
def f2(b):
    print b
def f3(c):
    print c

something similar to 
for i in range(3):
    pid = os.fork()
    if pid == 0:
       f1(a) # then call f2(b) in next iteration and then f3(c)in last iteration
       os._exit(0)

A:

func_map = {0: f1, 1: f2, 2: f3}

def parent(a):
    for i in range(3):
        pid = os.fork()
        if pid == 0:
            func_map[i](a)
            return

