Which function is responsible for main logic of /proc creation?

I have to achieve the behaviour mentioned in this question. Is /proc directory generated dynamically per request?

I suppose there is a function that loops through the task list and creates the corresponding entries. I am looking for something like that.

I looked for the functions that uses create_proc_entry() function but i could not find something that stands out.