NetApp Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

The fork system call will create the child process by copying the address space of the parent. It returns twice by returning the non-zero value to the parent process (the non-zero value is the child process id) and returns zero to the child process. Basically, it create a new process control block by copying from the parent process. The process control block (PCB) can be implemented as a structure which contains various information like process id, parent process id, process state and others. Once it creates a child process, it puts one process in the ready queue and other in the running state.

Data structures involved here are PCB structure, ready queue.

This answer is based on my knowledge. Please confirm.

- Srinivasan March 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

new PCB, schedulling, etc.
open files, code segment are shared.
environment variables, etc are inherited.

- AmitG November 12, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would like to add some more to Srinivasan's view.In addition to the PCB,the data structures such as the register tables are also created new for the child.

- Acecoder September 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <sys/types.h>

#define MAX_COUNT 200

void ChildProcess(void); /* child process prototype */
void ParentProcess(void); /* parent process prototype */

void main(void)
{
pid_t pid;

pid = fork();
if (pid == 0)
ChildProcess();
else
ParentProcess();
}

void ChildProcess(void)
{
int i;

for (i = 1; i <= MAX_COUNT; i++)
printf(" This line is from child, value = %d\n", i);
printf(" *** Child process is done ***\n");
}

void ParentProcess(void)
{
int i;

for (i = 1; i <= MAX_COUNT; i++)
printf("This line is from parent, value = %d\n", i);
printf("*** Parent is done ***\n");
}

- kingkong December 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

tree

- Anonymous July 27, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More